Hi everyone,
I was trying to refer to my worksheets by their indexes instead of names. However, the numbers I saw on the hierarchy were different from the actual worksheets I got from the codes. What did I get wrong?
For example, attached picture is the list of my sheets. Here is my test code:
The result is "Database" instead of "Data validation". It happens with all sheet excepts sheet 1.
Thanks in advance.
I was trying to refer to my worksheets by their indexes instead of names. However, the numbers I saw on the hierarchy were different from the actual worksheets I got from the codes. What did I get wrong?
For example, attached picture is the list of my sheets. Here is my test code:
VBA Code:
Sub Test()
Dim ws As Worksheet
Set ws = ThisWorkbook.Sheets(4)
MsgBox ws.Name
End Sub
The result is "Database" instead of "Data validation". It happens with all sheet excepts sheet 1.
Thanks in advance.