Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Can you create a global variable ?
Is there a way to make a variable in one macro available to other macros
? For example, how could the variable "i" in Macro_1 be available to Macro_2 ? Sub Macro_1() Dim i As Integer With Sheet2.ComboBox1 For i = 0 To .ListCount - 1 Sheet2.Range("Test") = .List(i) Macro_2 End Sub Sub Macro_2() Dim sFilename As String sFilename = "C:\Temp\" & Sheet2.Range("Data_Type").Text & " " & i & ".txt" ActiveWorkbook.SaveAs sFilename, xlText End Sub In Macro_2, a file will be output with names like the following depending on the number of iterations Macro_1 goes through: C:\Temp\Sales 0.txt C:\Temp\Sales 1.txt - Ronald K. |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Global Variable | Excel Discussion (Misc queries) | |||
global variable not seen | Excel Programming | |||
Global Variable | Excel Programming | |||
Global Variable | Excel Programming | |||
why is it saying sheetcnt is "variable not defined" how to do a global variable to share over multiple functions in vba for excel? | Excel Worksheet Functions |