Computing.Net > Forums > Programming > Can I call an Excel macro from cell

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Can I call an Excel macro from cell

Reply to Message Icon

Name: Mark Selden
Date: December 13, 2002 at 00:16:56 Pacific
OS: xp
CPU/Ram: 1.6/256
Comment:

Hello:
Is it possible to execute an excel macro based on condition of a cell?



Sponsored Link
Ads by Google

Response Number 1
Name: A Certain TH
Date: December 13, 2002 at 04:59:27 Pacific
Reply:

Yes. There are two ways to do it (that I can think of)

-you have an ongoing macro which automatically runs every second which checks the cells and executes your desired macro if a condition is met
-you have a routine which executes every time a change is made to the sheet which checks every cell, such as the following example:
Private Sub Worksheet_Change(ByVal Target As Excel.Range)
If Cells(1, 1) = "Hi" Then RunMeNow
End Sub
Sub RunMeNow()
MsgBox ("Hello to you too!")
End Sub

Right click on the name tab of a worksheet, select "View Code" and paste in that text. Do whatever you want on the sheet, and as soon as you enter the word "Hi" into cell A1, then the macro RunMeNow executes.

Hope that helps you

Tom


0
Reply to Message Icon

Related Posts

See More







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Programming Forum Home


Sponsored links

Ads by Google


Results for: Can I call an Excel macro from cell

Excel Macro www.computing.net/answers/programming/excel-macro/14702.html

Excel macro www.computing.net/answers/programming/excel-macro/15626.html

Excel Macro: Create XLS from Cell www.computing.net/answers/programming/excel-macro-create-xls-from-cell/18644.html