I am trying to place the matching sheet name into a variable. However, I can't figure out how to extra the sheet name. This returns the sheet the macro is executed from.
If I hardcode "NEEDED_SHEET"
by using
OrgSheet ="NEED_SHEET"
it works
What am I missing?
For Each ws In ActiveWorkbook.Sheets
If ws.Range("A1") = "ABC" Then ' found the program tab.
OrgSheet = ActiveSheet.Name
OrgSheet continues to be the Sheet the command button is located.
' clear sheet and exit loop
' Sheets(OrgSheet).Range("K24:T30").ClearContents
' Sheets(OrgSheet).Select
End If
Next ws
If I hardcode "NEEDED_SHEET"
by using
OrgSheet ="NEED_SHEET"
it works
What am I missing?
For Each ws In ActiveWorkbook.Sheets
If ws.Range("A1") = "ABC" Then ' found the program tab.
OrgSheet = ActiveSheet.Name
OrgSheet continues to be the Sheet the command button is located.
' clear sheet and exit loop
' Sheets(OrgSheet).Range("K24:T30").ClearContents
' Sheets(OrgSheet).Select
End If
Next ws