View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Tom Ogilvy Tom Ogilvy is offline
external usenet poster
 
Posts: 27,285
Default Pass variable to macro

Public sCol As String


must be declared in the general/standard module at the very top outside any
procedures.

--
Regards,
Tom Ogilvy

"Jason Morin" wrote in message
...
Hello and TIA. I'm trying to pass along a variable from a workbook_open

macro
to another macro, but the variable is not getting passed along. The macro
"GenerateWord" in a standard module isn't recognizing "sCol".

Public sCol As String
Sub Workbook_Open()
sCol = InputBox("Enter column.")
GenerateWord
End Sub

Sub GenerateWord()
Dim iLastRow As Long
'Set range
With Workbooks("words.xls").Sheets("test")
iLastRow = .Cells(Rows.Count, sCol).End(xlUp).Row 'error occurs here
......
End Sub

Regards,
Jason