Results 1 to 4 of 4

Toggle button works on sheet but not when moved to module.

Threaded View

  1. #1
    Registered User
    Join Date
    12-02-2012
    Location
    Silver Bay, MN
    MS-Off Ver
    Excel 2010
    Posts
    47

    Toggle button works on sheet but not when moved to module.

    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.
    Last edited by mandora; 12-27-2012 at 04:39 AM. Reason: Added Code Tags

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1