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

Can I call an Excel macro from cell

Reply to Message Icon

Original Message
Name: Mark Selden
Date: December 13, 2002 at 00:16:56 Pacific
Subject: Can I call an Excel macro from cell
OS: xp
CPU/Ram: 1.6/256
Comment:

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


Report Offensive Message For Removal


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

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


Report Offensive Follow Up For Removal







Use following form to reply to current message:

   Name: From My Computing.Net Settings
 E-Mail: From My Computing.Net Settings

Subject: Can I call an Excel macro from cell

Comments:

 


  Homepage URL (*): 
Homepage Title (*): 
         Image URL: 
 
Data Recovery Software




Have you ever used OpenOffice?

Yes, as my main suite.
Yes, occationally.
Yes, but only once.
No, never.


View Results

Poll Finishes Today.
Discuss in The Lounge