I placed a toggle button on a userform that toggles between two sheets. Originally, I placed the code with the button as a click event and its worked fine.
Subequently, I moved the toggle code to a standard module and called it from the forms object. The call works but the toggle code itself produces "Object variable or With block variable not set". Code follows:
Code In forms object:
Sub btnToggleSheets_Click()
ToggleSheets
End Sub
Code in standard module with Option Explicit set:
Sub ToggleSheets()
If btnToggleSheets.Value = True Then
btnToggleSheets.Caption = "SWITCH TO BUDGET SUMMARY"
Sheets("Data Sheet").Select
End If
If btnToggleSheets.Value = False Then
btnToggleSheets.Caption = "SWITCH TO DATA SHEET"
Sheets("Budget Summary").Select
End If
End Sub
I am self-taught and obviously have a lot to learn. Your help will be appreciated.
Bookmarks