i am trying to create a sub which will be passed a sheet name and then select, and clear the contents of the sheet it was passed.
the code i am using for the sub is:
and the code i use to call the sub is:
however when i try to run the macro i get the following error:
"Run-time error '9':
Subscript out of Range"
and when I click debug, it returns me to the line in my sub that says:
is there something different i need to dodo pass a variable to my sub?
the code i am using for the sub is:
Code:
Sub ClearSheet(sheetName)
'
' selectSheet Macro
' Macro recorded 2/12/2004 by BDEE1
'
'
Sheets(sheetName).Select
Cells.Select
Selection.ClearContents
End Sub
and the code i use to call the sub is:
Code:
Call ClearSheet(sheet1)
however when i try to run the macro i get the following error:
"Run-time error '9':
Subscript out of Range"
and when I click debug, it returns me to the line in my sub that says:
Code:
Sheets(sheetName).Select
is there something different i need to dodo pass a variable to my sub?