tiredofit
Well-known Member
- Joined
- Apr 11, 2013
- Messages
- 1,926
- Office Version
- 365
- 2019
- Platform
- Windows
IF I know my workbook has a worksheet called Apples, I can refer to it as follows:
but I DON'T know for certain there's a worksheet called Apples because the user might change it.
Instead I DO know there's a worksheet with a codename of wksApples.
So how can incorporate this into my code?
This doesn't work:
I don't want to have to do this:
Thanks
Code:
With wb.Worksheets("Apples")
' Do something
End With
but I DON'T know for certain there's a worksheet called Apples because the user might change it.
Instead I DO know there's a worksheet with a codename of wksApples.
So how can incorporate this into my code?
This doesn't work:
Code:
With wb.Worksheets(wksApples.Codename)
' Do something
End With
I don't want to have to do this:
Code:
Dim ws As Worksheet
For Each ws In wb.Worksheets
If ws.CodeName = "wksApples" Then
Exit For
End If
Next ws
With ws
' Do something
End With
Thanks
Last edited: