ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   variable in excel (https://www.excelbanter.com/excel-programming/311977-variable-excel.html)

anang

variable in excel
 
I have little problem with my macro. How to assign the value of the
variable to other macro which I call in main macro.

Sub Macro1()
sheet_name = "Measurement 1"
Call Looping
Call Positifing
End Sub

I have "sheet_name" variable inside the Looping and Positifing macros
..

JulieD

variable in excel
 
Hi

you need to declare the variable at the top of the module sheet
Dim sheet_name as String
if all of the code is in the same module sheet.

If it isn't you need to declare the variable as
Public sheet_name as String
at the top of a module sheet

Hope this helps
Cheers
JulieD

"anang" wrote in message
om...
I have little problem with my macro. How to assign the value of the
variable to other macro which I call in main macro.

Sub Macro1()
sheet_name = "Measurement 1"
Call Looping
Call Positifing
End Sub

I have "sheet_name" variable inside the Looping and Positifing macros
.




Colo[MVP Excel]

variable in excel
 
Hi,

Here is another way. You can pass the variable as an argument as follows.

Sub Macro1()
Dim sheet_name As String
sheet_name = "Measurement 1"
Call Looping(sheet_name)
Call Positifing(sheet_name)
End Sub

Sub Looping(ByVal Sh_Name)
MsgBox Sh_Name
End Sub

Sub Positifing(ByVal Sh_Name)
MsgBox Sh_Name
End Sub


Regards,
Colo


"anang" wrote in message
om...
I have little problem with my macro. How to assign the value of the
variable to other macro which I call in main macro.

Sub Macro1()
sheet_name = "Measurement 1"
Call Looping
Call Positifing
End Sub

I have "sheet_name" variable inside the Looping and Positifing macros
.



ijb[_2_]

variable in excel
 
declare the variable public outside the main routine

Public sheet_name as String
Sub Macro1()
sheet_name = "Measurement 1"
Call Looping
Call Positifing
End Sub

--
If I've mis-understood the question please tell me.

HTH

ijb

Remove nospam from my e-mail address to talk direct

Not MCSD, MVP, TLA, P&P, PCMCIA, etc just trying to help


"anang" wrote in message
om...
I have little problem with my macro. How to assign the value of the
variable to other macro which I call in main macro.

Sub Macro1()
sheet_name = "Measurement 1"
Call Looping
Call Positifing
End Sub

I have "sheet_name" variable inside the Looping and Positifing macros
.




ijb[_2_]

variable in excel
 
declare the variable public outside the main routine

Public sheet_name as String
Sub Macro1()
sheet_name = "Measurement 1"
Call Looping
Call Positifing
End Sub

--
If I've mis-understood the question please tell me.

HTH

ijb

Remove nospam from my e-mail address to talk direct

Not MCSD, MVP, TLA, P&P, PCMCIA, etc just trying to help


"anang" wrote in message
om...
I have little problem with my macro. How to assign the value of the
variable to other macro which I call in main macro.

Sub Macro1()
sheet_name = "Measurement 1"
Call Looping
Call Positifing
End Sub

I have "sheet_name" variable inside the Looping and Positifing macros
.






All times are GMT +1. The time now is 08:55 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com