Link to home
Start Free TrialLog in
Avatar of j8547
j8547

asked on

declare worksheet as constant

I have 3 worksheet in my workbook. I have declared them ws1 = .... ws2 = ..... ws3=.......

I have to constantly set them as i use them in most modules. How can i set them once at the begining and then reference them after.
Avatar of ExcelGuide
ExcelGuide
Flag of Netherlands image

did you already try:
Public ws1, ws2, ws3

at the beginning of your code, so something like
Public ws1, ws2, ws3
Sub yourcode()
{yoour code
ws1 = "sheet1"
}
End Sub
Avatar of j8547
j8547

ASKER

I have Public ws1, ws2, ws3 at the top. Then in my code i have set ws 1 = thisworkbook.worksheet......
the problem is i have to do this in every Sub. If i say use ws 1 without setting it again i get an error. I was looking to only set it once and thats it. Can this be done
ASKER CERTIFIED SOLUTION
Avatar of ExcelGuide
ExcelGuide
Flag of Netherlands image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial