MrExcel Publishing
Your One Stop for Excel Tips & Solutions

passing a variable to a macro


Posted by Kelly on August 31, 2001 6:55 AM

Hi,

I've recorded a few macros in Excel, and am now starting to get into the Visual Basic side of things. I would like to pass a variable in and out of these macros, in this particular case macros describing combo boxes.

In my very limited knowledge, I've tried defining the variable at the start of the sheet code and changing the private sub macros to public sub or just sub, but still

Sub ComboBox1_Change(variable As Integer)

comes up with a compile error when I go back to Excel.

Could someone suggest what I am doing wrong, or perhaps suggest a better route?


Posted by gregc on August 31, 2001 8:32 AM

For the occasional hack like myself. Just put the value in a cell somewhere out of the way and just refer to that cell when you need the value.