View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
GS[_2_] GS[_2_] is offline
external usenet poster
 
Posts: 3,514
Default Can you create a global variable ?

kittronald explained :
Isabelle,

Thanks for getting up early or not sleeping !

Do I put the following in Macro_1 or in the code of one of the worksheets
?

Public i As Integer


- Ronald K.


I do not advise you do this! Rather, declare an argument for Macro_2
and pass "i" to it.

Macro_1()
Dim i As Integer
With Sheet2.ComboBox1
For i = 0 To .ListCount - 1
Sheet2.Range("Test") = .List(i)
Macro_2 CStr(i) '//***
Next 'i
End With 'Sheet2.ComboBox1
End Sub

Sub Macro_2(Ndx As String)
Dim sFilename As String
sFilename = "C:\Temp\" _
& Sheet2.Range("Data_Type").Text _
& " " & Ndx & ".txt"
ActiveWorkbook.SaveAs sFilename, xlText
End Sub

--
Garry

Free usenet access at http://www.eternal-september.org
ClassicVB Users Regroup! comp.lang.basic.visual.misc