• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Change cell content - clear adjacent cell

lorenzo_b

New Member
I'm trying to find a way to have my spreadsheet clear the contents of one cell when a user makes a choice from a drop-down list in an adjacent cell in the same row. I've tried a couple of VBA scripts, without success. Any tips?
 
Would need to know more specifics to get things perfect, but here's the basic structure. This is an event macro, so you need to right-click on the worksheet, view code, paste this in. Modify as needed.

[pre]
Code:
Private Sub Worksheet_Change(ByVal Target As Range)
'Check if the user made a change in col B
If Intersect(Target, Range("B:B")) Is Nothing Then Exit Sub
'Check if multiple cells were affected. Might be able to handle this,
'but for now we'll ignore
If Target.Count > 1 Then Exit Sub

'turn off the triggers, since our code is about to make a
'change to the worksheet and we don't want to trigger
'another event. =P
Application.EnableEvents = False

'Clear the cell from col A in the target's row
Cells(Target.Row, "A").ClearContents

'turn trigger back on
Application.EnableEvents = True

End Sub
[/pre]
 
Back
Top