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

Activate VBA code from specific cells on data entry

Status
Not open for further replies.

Magnetar

Programmer
Sep 22, 2001
73
GB
Hello everyone!

Am very new to Excel VBA, & need help urgently in the following area (please!). On clicking into a range of cells, need to activate a MsgBox.

Example of this is range A40:A50, within worksheet1.

Example of code under worksheet1 is:

Private Sub Worksheet_SelectionChange(ByVal Target As Range)

If Sheet1.Range(A39, A43) Then

StaffCosts

End If

End Sub


Code will then call a sub/function to display message, as per following example:

Sub StaffCosts()

MsgBox "[Message]", vbInformation + vbOKOnly, "[Title of Message to Users]"

End Sub


As mentioned above am very, very new to Excel VBA. Basically I would like to know the Excelequivalent of the appropriate event for the cell ranges upon which to trigger the above message from code, (similar to events on forms within MS Access).

Further note: have successfully managed to manually run the code from the Tools | Macro | Macros...|Run menu.

However I want to trigger the msgbox each time the user selects a value from a drop-down list, and enters this into cells A40 to A50.

Would really appreciate some help with this very soon. Many, many thanks in advance.

Kind regards, - Magnetar [atom]




 
Hi
try
if target.address = "$A$40:$A$50" then
call othersub
end if

Also, you should post questions like this in the VBA forum!

;-)
If a man says something and there are no women there to hear him, is he still wrong? [ponder]
How do I get the best answers?
 
Loomah, hi there.

Many thanks for your response.

Will repost and continue this conversation now, within the VBA forum (sorry didn't realise I should have posted there in the first place!).

Kind regards, - Magnetar [atom]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top