Jump to content
Macro Express Forums

Spreadsheet Cell Contents To Start Macro


RookieTrader

Recommended Posts

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

Link to comment
Share on other sites

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!

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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:

  1. Launches or activates the spreadsheet
  2. Goes to a particular cell
  3. Stuffs the clipboard with the value
  4. Runs another macro based on the value
  5. 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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...