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 Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Excel VBA Newbie

Status
Not open for further replies.

HobbitK

Technical User
Jan 14, 2003
235
US
Hi everyone.. I am a VB programmer but am quickly realizing I know little about VBA.

Question is this ...
How do I call a VBA sub from a cell when its value(either numbers or text) changes?
Thanks
Michael
 
VB Editor > click on the sheet object you want, then use the drop-down menus at the top of the code window (there are two of them) to get the Change event for that Sheet.

The Sub shell will be constructed for you, all you have to do is enter the routine name and put it's arguments in brackets afterwards if required.
 
Just to expand on the above you'll need to check that the cell changed is the one from which you want to run your routine. By way of example:-

Code:
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Address = "$A$1" Then MsgBox "Hello" 'your routine!!
End Sub

If you don't have something similar to this your routine will run whenever any cell in the sheet is changed.

;-) If a man says something and there are no women there to hear him, is he still wrong? [ponder]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top