abdelfattah
Well-known Member
- Joined
- May 3, 2019
- Messages
- 1,429
- Office Version
- 2019
- 2010
- Platform
- Windows
hi
I want fixing this error subscript ou of range when write error sheet name in cell A2
my goal if the sheet name is wrong then should populate MsgBox "please check the right sheet name"
and if sheet name is right then should activate sheet .
here is my code
I want fixing this error subscript ou of range when write error sheet name in cell A2
my goal if the sheet name is wrong then should populate MsgBox "please check the right sheet name"
and if sheet name is right then should activate sheet .
here is my code
VBA Code:
Sub activate_sh()
Dim ws As Variant
For Each ws In Array("a", "b", "d")
If Worksheets(Worksheets("ACTIVATE").Range("A2").Text) <> ws.Name Then
MsgBox "please check the right sheet name"
Else
Worksheets(Worksheets("ACTIVATE").Range("A2").Text).Activate
End If
Next
End Sub