Vivek
Vivek

Reputation: 255

Excel VBA Events

I'm a little new to Excel VBA. I've currently designed VBA code to produce a Vlookup that populates data in a column(say column Y) in my datasheet based on ref data in another sheet, and a filled value in another column (column X) of the same sheet. This I'm performing on the Workbook_Open event.

I need to, however, also be able to update column Y's value when column X's value is changed in a particular row. Also, if an additional row is added, I need to be able to provide a Y value for that too. However, I can't seem to find an appropriate event for the same, barring the selection changed event at Worksheet level, which is triggered when u change which cell you've selected.

Upvotes: 0

Views: 378

Answers (1)

John Bustos
John Bustos

Reputation: 19574

Try the worksheet change event... To ensure something happened in Column X, you would write somethign like this:

Private Sub Worksheet_Change(ByVal Target As Range)
 If Not Intersect(Target, Range("X:X")) Is Nothing Then
   MsgBox ("Hi")
 End If
End Sub

Hope this helps

Upvotes: 1

Related Questions