I have my spreadsheet set up so that it tells me when conditions are such that I need to run a macro. I click a button that runs the macro and turns the "run macro" message off. Now I need to automate this function so that macro runs whenever it needs to, just like calculations that are automatically updated when a cell value changes. I have found some useful threads here on MrExcel.com that pointed me in the right direction, but I am struggling with the proper syntax to run my macro.
Currently, my button-click macro ("MaxGW") resides in Module3. I have the following code in Microsoft Excel Objects/Sheet1 (Display) on which the cell I am testing is located. The controlling cell contains a formula that results in either True or False. The code appears to be working properly (i.e., identifying whether the control cell is True or False), but I can't figure out the proper syntax to run my macro. I've tried moving the macro from Module3 to Sheet1, but still couldn't figure out the syntax to run the macro. With the coding below I get the error messages: Run time error '50290': Method 'Run' of object '_Application' failed.
Private Sub Worksheet_Calculate()
x = Worksheets("Display").Cells(33, 6).Value
If x = True Then
Application.Run "'myfilename.xls'!Module3.MaxGW"
End If
End Sub
(I got this syntax by recording a new macro, pressing my macro button, and looking at the VBA code that was produced.)
Thanks in advance to anyone who can point me down the correct path.
Scott
Excel 2003/Visual Basic 6.5
Currently, my button-click macro ("MaxGW") resides in Module3. I have the following code in Microsoft Excel Objects/Sheet1 (Display) on which the cell I am testing is located. The controlling cell contains a formula that results in either True or False. The code appears to be working properly (i.e., identifying whether the control cell is True or False), but I can't figure out the proper syntax to run my macro. I've tried moving the macro from Module3 to Sheet1, but still couldn't figure out the syntax to run the macro. With the coding below I get the error messages: Run time error '50290': Method 'Run' of object '_Application' failed.
Private Sub Worksheet_Calculate()
x = Worksheets("Display").Cells(33, 6).Value
If x = True Then
Application.Run "'myfilename.xls'!Module3.MaxGW"
End If
End Sub
(I got this syntax by recording a new macro, pressing my macro button, and looking at the VBA code that was produced.)
Thanks in advance to anyone who can point me down the correct path.
Scott
Excel 2003/Visual Basic 6.5