Featured Product

Excel Daily News

passing a variable to a macro

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.

(8 responses) I have a column with either a value of 1 or blank. The sheet has a header. Is there code that can sort by value in column "Z", find the last

Let's Connect

MrExcel.com debuted on November 21, 1998.

MrExcel.com provides examples of Formulas, Functions and Visual Basic procedures
for illustration only, without warranty either expressed or implied, including
but not limited to the implied warranties of merchantability and/or fitness for
a particular purpose. The Formulas, Functions and Visual Basic procedures on this
web site are provided "as is" and we do not guarantee that they can be used in all
situations.
This site contains affiliate links. Any affiliate commissions that we
earn when you click a link to Amazon or other sites is reinvested in keeping MrExcel.com
running. You can earn a commission for sales leads that you send to us by joining our
affiliate program.
View our Privacy Policy, Cookies Policy, and Terms of Use.