Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Excel event handling

Status
Not open for further replies.

toryee

Technical User
Aug 14, 2003
23
US
Hi,

I'm using Excel VBA and I need to check the value of a cell after the user updates it. This check needs to be performed for all cells in a column. I think I probably need to use an event handler, but don’t quite understand how they work. What's the concept and syntax for event handler? Is there a change_cell event? I have tried putting the code in worksheet_change and worksheet_selectionchange, but couldn’t get it working.

Any explanation is appreciated.
Toryee

 
do a keyword search in this forum for intersect target

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
go to the VBA Editor and double click on the worksheet tab in the project you are working on. Select "Worksheet" from the drop down on the left side of the module and "Change" on the right side of the module.

you will see something like this appear:
Code:
Option Explicit

Private Sub Worksheet_Change(ByVal Target As Range)

End Sub

Place this code in the private sub
Code:
If target.column = [your column choice here] Then
   'Code you want to execute
End If
Should do the trick. You might want to assign a range name to the column so that it will change if columns are added or deleted in your data. You can specify the column number by:
Code:
Range("name_of_range").column
Hope this helps

 
Thank you guys for your inputs.
I did search on 'intersect target' and have found some helpful posts. Anyhow, I got it working using Worksheet_Change with EnableEvent property.

Regards,
Toryee


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top