Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
Ed Ed is offline
external usenet poster
 
Posts: 46
Default Variable values

I've set up two macros "A" and "B" for use on a worksheet.

I assigned a value say 4 to a variable "v" in macro A.

I find that the value 4 does not carry over to a variable "v" in
macro B.

Is there a way to have the variables of macro A apply to all other
macros used with the worksheet?

Thanks,


Ed
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,058
Default Variable values

DIM the variable before the macros in the module:

DIM v
Sub a()
..
..
..
End Sub
Sub b()
..
..
..
End Sub
--
Gary''s Student


"Ed" wrote:

I've set up two macros "A" and "B" for use on a worksheet.

I assigned a value say 4 to a variable "v" in macro A.

I find that the value 4 does not carry over to a variable "v" in
macro B.

Is there a way to have the variables of macro A apply to all other
macros used with the worksheet?

Thanks,


Ed

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 138
Default Variable values


"Ed" wrote in message
...
I've set up two macros "A" and "B" for use on a worksheet.

I assigned a value say 4 to a variable "v" in macro A.

I find that the value 4 does not carry over to a variable "v" in
macro B.

Is there a way to have the variables of macro A apply to all other
macros used with the worksheet?


If the macros are in one module: put a 'Dim v' statement at the beginning of
the module (in the General section). Your variable will be recognizes in all
macros (do not but a Dim v statement into any of your macros, this would
override the general declaration.

If macros are in separate modules, put a 'Public v' statement into the
general section of any module.

Joerg


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
Assigning values to a variable set John A[_2_] Excel Discussion (Misc queries) 1 April 23rd 10 08:20 PM
Sum of values in variable range Lawman Excel Discussion (Misc queries) 5 March 30th 08 01:13 PM
variable for Y values in chart Don Barton Charts and Charting in Excel 2 January 9th 08 05:47 PM
SUM formula - using variable values Mike C Excel Worksheet Functions 2 January 13th 06 10:58 PM
Maintaining VBA variable values Adam1 Chicago Excel Discussion (Misc queries) 3 March 14th 05 11:08 PM


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