#1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default Variables

I'm new to VBA and I'm trying to define a variable in one
subroutine and use it in another subroutine but the
variable is resetting to zero in the second subroutine.
What am I missing? Thank you for any help with this.

Sub DownOne()
RowOffset = 1 'defining the variable
Combine 'Second Subroutine
End Sub

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 783
Default Variables

Tim U wrote:

I'm new to VBA and I'm trying to define a variable in one
subroutine and use it in another subroutine but the
variable is resetting to zero in the second subroutine.
What am I missing? Thank you for any help with this.

Sub DownOne()
RowOffset = 1 'defining the variable
Combine 'Second Subroutine
End Sub

You might try

Sub Combine(rowOffset)
'whatever
End Sub

Sub DownOne()
RowOffset = 1
Call Combine(RowOffset)
End Sub

Alan Beban
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 44
Default Variables

Try declaring the variable as Public, at the very top of
the module. Public makes the variable available to all
modules in all, declaring them as Private makes the
variable only available to all procedures in the same
module. Have a look under Help, Declaring variables. Or
look at Public, Private and static to find which
declaration best suits your needs.

All the best

DavidC
-----Original Message-----
I'm new to VBA and I'm trying to define a variable in one
subroutine and use it in another subroutine but the
variable is resetting to zero in the second subroutine.
What am I missing? Thank you for any help with this.

Sub DownOne()
RowOffset = 1 'defining the variable
Combine 'Second Subroutine
End Sub

.

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
Not at all clear on use of variables and/or object variables JMay-Rke Excel Discussion (Misc queries) 11 July 4th 08 06:36 PM
More than 1 Variables [email protected] Excel Discussion (Misc queries) 1 November 29th 06 02:09 AM
DIm Variables Todd Huttenstine Excel Programming 4 April 26th 04 04:37 PM
Variables richie Excel Programming 1 October 16th 03 06:44 PM
variables jim c. Excel Programming 1 October 16th 03 01:31 PM


All times are GMT +1. The time now is 04:25 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"