RookieTrader Posted July 26, 2004 Report Share Posted July 26, 2004 Looking for a little help starting a macro. Can the results of a calculation in a spreadsheet cell start a macro? The result of 1 could start macro A, a 0 could start macro B just as an example. Is this possible with Macro Express? I feel sure it is but I haven't figured out how to do it yet. The spreadsheet is not excel but is something similiar. Any help would be greatly appreciated. David Quote Link to comment Share on other sites More sharing options...
PaulMurphy Posted July 26, 2004 Report Share Posted July 26, 2004 Hello RookieTrader Under Logic you can find a simple "if" statement and a switch statement for more complicated questions. Hope this helps. Quote Link to comment Share on other sites More sharing options...
joe Posted July 26, 2004 Report Share Posted July 26, 2004 Hello! As Paul says, one of the logical constructs would seem to fit the bill. Here are a couple of examples: // Highlight target cell and then: Clipboard Copy Variable Set Integer %N1% from Clipboard If Variable %N1% = 0 Macro Run: Macro A Else Macro Run: Macro B End If // Or using a Switch / End Switch construct: Clipboard Copy Variable Set Integer %N1% from Clipboard Switch (N1) Case: 0 Macro Run: Macro A End Case Case: 1 Macro Run: Macro B End Case Case: 2 Macro Run: Macro C End Case Case: 3 Macro Run: Macro D End Case End Switch Hope this helps! Quote Link to comment Share on other sites More sharing options...
RookieTrader Posted July 27, 2004 Author Report Share Posted July 27, 2004 Joe & Paul, Thanks for your replies. I have more questions for you though. I see how your code reads from the clipboard and then runs a macro depending on the clipboard contents, but I don't see how to get the contents of a spreadsheet cell to the clipboard automatically. Can a macro have a spreadsheet cell as an input and monitor the value of the cell? Can it then run the IF and Else commands using the cells value to determine which macro to run? I would like to continually monitor the values in a few spreadsheet cells and have a macro act on those values. I would need to be able to list the cell by file name, sheet #, and cell location on the spreadsheet to do this I think. Any ideas on how this could be accomplished? The only values for the cell would be 0 or 1. The macro could then act from there but how do I get it to read the value of the cell? Thanks for your help. David Quote Link to comment Share on other sites More sharing options...
joe Posted July 28, 2004 Report Share Posted July 28, 2004 Individual cells in a spreadsheet apparently cannot be captured to a Window Control, so that option is out. Maybe you could do something behind the scenes instead. Create a scheduled macro that: Launches or activates the spreadsheet Goes to a particular cell Stuffs the clipboard with the value Runs another macro based on the value Waits for the next scheduled time to fire This could be done with having the spreadsheet invisible and there are several different kinds of schedules available depending on how often, and when, you want the macro to run. Quote Link to comment Share on other sites More sharing options...
Pete Posted July 29, 2004 Report Share Posted July 29, 2004 Hi. I have an application which does just this many thousands of times a day. ME passes control to Excel and waits for a dialog box before it continues. It works like this... ME focuses excel workbook. ME sends keystrokes [alt+z] to run Excel macro (VBA). ME waits for CLIPBOARD READY window. Excel Macro does some stuff, then goes to cell and copies to clipboard. Excel Macro spawns CLIPBOARD READY dialog box. ME sends keystroke [ENTER] to close CLIPBOARD READY dialog box. ME populates variable from clipboard. --------- Hope this helps Pete. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.