Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Adam1 Chicago
 
Posts: n/a
Default Global Variable -- Excel / VBA

I currently have a module in VBA that has 6 macros in it. In the third macro
I search down a column that was populated in the second macro. When I
encounter an empty row, I go back up one row and call that row ticker_end
(ticker_end = ActiveCell.Row).

However, when I got to macros 4-6 they don't recognize ticker_end and I have
to search through the column again for the condition I want and re-name the
variable at the start of each macro.

Considering that I can't create the variable before macro 3 because it
depends on actions in macros 2, is there some way once I do set ticker_end I
can make it keep its value through macros 4-6?

Thank you
  #2   Report Post  
Trevor Shuttleworth
 
Posts: n/a
Default

dim ticker_end as long

:
sub macro2()
:
end sub
sub macro3()
:
ticker_end = ActiveCell.Row
:
end sub
sub macro4()
:
msgbox ticker_end
:
end sub

Regards

Trevor


"Adam1 Chicago" wrote in message
...
I currently have a module in VBA that has 6 macros in it. In the third
macro
I search down a column that was populated in the second macro. When I
encounter an empty row, I go back up one row and call that row ticker_end
(ticker_end = ActiveCell.Row).

However, when I got to macros 4-6 they don't recognize ticker_end and I
have
to search through the column again for the condition I want and re-name
the
variable at the start of each macro.

Considering that I can't create the variable before macro 3 because it
depends on actions in macros 2, is there some way once I do set ticker_end
I
can make it keep its value through macros 4-6?

Thank you



  #3   Report Post  
Adam1 Chicago
 
Posts: n/a
Default

Trevor,

Thanks for your reply. I put in "msgbox ticker_end", but it just gave me a
message box and then still didn't recognize ticker_end. I'm sure I'm missing
something simple in your response, but if you help me a little more I'd
appreciate it.

Thanks,
Adam

"Trevor Shuttleworth" wrote:

dim ticker_end as long

:
sub macro2()
:
end sub
sub macro3()
:
ticker_end = ActiveCell.Row
:
end sub
sub macro4()
:
msgbox ticker_end
:
end sub

Regards

Trevor


"Adam1 Chicago" wrote in message
...
I currently have a module in VBA that has 6 macros in it. In the third
macro
I search down a column that was populated in the second macro. When I
encounter an empty row, I go back up one row and call that row ticker_end
(ticker_end = ActiveCell.Row).

However, when I got to macros 4-6 they don't recognize ticker_end and I
have
to search through the column again for the condition I want and re-name
the
variable at the start of each macro.

Considering that I can't create the variable before macro 3 because it
depends on actions in macros 2, is there some way once I do set ticker_end
I
can make it keep its value through macros 4-6?

Thank you




  #4   Report Post  
Trevor Shuttleworth
 
Posts: n/a
Default

Adam

you need to define the field once and once only ... before all the code.
Check to see if you still have a dim statement in one or more of the
modules. If you have, that will over-ride the global definition.

Regards

Trevor


"Adam1 Chicago" wrote in message
...
Trevor,

Thanks for your reply. I put in "msgbox ticker_end", but it just gave me
a
message box and then still didn't recognize ticker_end. I'm sure I'm
missing
something simple in your response, but if you help me a little more I'd
appreciate it.

Thanks,
Adam

"Trevor Shuttleworth" wrote:

dim ticker_end as long

:
sub macro2()
:
end sub
sub macro3()
:
ticker_end = ActiveCell.Row
:
end sub
sub macro4()
:
msgbox ticker_end
:
end sub

Regards

Trevor


"Adam1 Chicago" wrote in message
...
I currently have a module in VBA that has 6 macros in it. In the third
macro
I search down a column that was populated in the second macro. When I
encounter an empty row, I go back up one row and call that row
ticker_end
(ticker_end = ActiveCell.Row).

However, when I got to macros 4-6 they don't recognize ticker_end and I
have
to search through the column again for the condition I want and re-name
the
variable at the start of each macro.

Considering that I can't create the variable before macro 3 because it
depends on actions in macros 2, is there some way once I do set
ticker_end
I
can make it keep its value through macros 4-6?

Thank you






Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
I get a program error when I download an excel template Ladybug Excel Discussion (Misc queries) 3 March 4th 05 12:02 AM
html to excel nellie Excel Discussion (Misc queries) 4 February 8th 05 10:37 PM
Excel error - Startup (and Acrobat PDFMaker) gxdata Setting up and Configuration of Excel 0 February 4th 05 03:44 AM
Merge from Excel to Excel dalstar Excel Discussion (Misc queries) 3 January 30th 05 02:37 PM
Shortcut file fails to open JimH Excel Discussion (Misc queries) 3 January 15th 05 10:13 PM


All times are GMT +1. The time now is 10:31 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"