View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
Bob Phillips Bob Phillips is offline
external usenet poster
 
Posts: 10,593
Default Referring to a Worksheet with a variable

Set VBComp = ThisWorkbook.VBProject.VBComponents(MySh)


--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)

"donbowyer" wrote in message
...
This The expression works OK:-
Set VBComp = ThisWorkbook.VBProject.VBComponents("Sheet1")
But what is the correct syntax if I want to refer to a sheet with a

variable
number?
Suppose the variable sheet number is MySh, then ("SheetMySh") produces a
runtime error "Script out of range"
--
donwb