+ Reply to Thread
Results 1 to 6 of 6

Code unable to debug, how to run continuously?

Hybrid View

lazyengineer Code unable to debug, how to... 07-14-2015, 02:02 PM
TMS Re: Code unable to debug, how... 07-14-2015, 02:23 PM
lazyengineer Re: Code unable to debug, how... 07-14-2015, 02:25 PM
TMS Re: Code unable to debug, how... 07-14-2015, 03:07 PM
lazyengineer Re: Code unable to debug, how... 07-15-2015, 10:32 AM
TMS Re: Code unable to debug, how... 07-15-2015, 12:00 PM
  1. #1
    Registered User
    Join Date
    06-10-2015
    Location
    USA
    MS-Off Ver
    2013
    Posts
    37

    Code unable to debug, how to run continuously?

    Hey guys! I have outlined my code below.

    So basically I have two different things happening here, one part is hiding rows based off of a selected dropdown setting, the next hides/shows pictures of signatures based off of a name selection dropdown. I know both of these pieces of code work, but for some reason I can't get them to run continuously, and I can't even debug them, f8 doesn't allow me to run through them. Any idea why? Any help would be appreciated. Thanks guys!

    Private Sub Worksheet_Change(ByVal Target As Range)
        Dim Employee_select As String
    
        Select Case Range("OF_CHANNELS").value
            Case Is = "# OF CHANNELS"
    'First case select shows rows to prevent case overlap
                Sheets("HARTLAND").Rows("83:350").Hidden = False
    'Second case select hides rows
                Sheets("HARTLAND").Rows("73:350").Hidden = False
            Case Is = "1"
                Sheets("HARTLAND").Rows("83:350").Hidden = False
                Sheets("HARTLAND").Rows("73:350").Hidden = True
            Case Is = "2"
                Sheets("HARTLAND").Rows("73:350").Hidden = False
                Sheets("HARTLAND").Rows("83:350").Hidden = True
            Case Is = "3"
                Sheets("HARTLAND").Rows("83:350").Hidden = False
                Sheets("HARTLAND").Rows("93:350").Hidden = True
            Case Is = "4"
                Sheets("HARTLAND").Rows("83:350").Hidden = False
                Sheets("HARTLAND").Rows("103:350").Hidden = True
            Case Is = "5"
                Sheets("HARTLAND").Rows("83:350").Hidden = False
                Sheets("HARTLAND").Rows("113:350").Hidden = True
            Case Is = "6"
                Sheets("HARTLAND").Rows("83:350").Hidden = False
                Sheets("HARTLAND").Rows("123:350").Hidden = True
    
        End Select
    'Shows employee signature based off of selected name
        'JIM WAGNER
        If Range("Employee_Select").value = "JIM WAGNER" Then
        Sheets("HARTLAND").Shapes("JIM_WAGNER").Visible = True
            Sheets("HARTLAND").Shapes("Blank").Visible = True
            Sheets("HARTLAND").Shapes("blank1").Visible = True
            Sheets("HARTLAND").Shapes("blank2").Visible = True
            Sheets("HARTLAND").Shapes("blank3").Visible = True
        Else
            Sheets("HARTLAND").Shapes("JIM_WAGNER").Visible = False
        End If
        'MIKE FLEISCHMANN
        If Range("Employee_Select").value = "MIKE FLEISCHMANN" Then
            Sheets("HARTLAND").Shapes("MIKE_FLEISCHMANN").Visible = True
            Sheets("HARTLAND").Shapes("blank").Visible = True
            Sheets("HARTLAND").Shapes("blank1").Visible = True
            Sheets("HARTLAND").Shapes("blank2").Visible = True
            Sheets("HARTLAND").Shapes("blank3").Visible = True
        Else
            Sheets("HARTLAND").Shapes("MIKE_FLEISCHMANN").Visible = False
        End If
        'ROBIN HENNEN
        If Range("Employee_Select").value = "ROBIN HENNEN" Then
            Sheets("HARTLAND").Shapes("ROBIN_HENNEN").Visible = True
            Sheets("HARTLAND").Shapes("blank").Visible = True
            Sheets("HARTLAND").Shapes("blank1").Visible = True
            Sheets("HARTLAND").Shapes("blank2").Visible = True
            Sheets("HARTLAND").Shapes("blank3").Visible = True
        Else
            Sheets("HARTLAND").Shapes("ROBIN_HENNEN").Visible = False
        End If
        'SHANNON BURTON
        If Range("Employee_Select").value = "SHANNON BURTON" Then
            Sheets("HARTLAND").Shapes("SHANNON_BURTON").Visible = True
            Sheets("HARTLAND").Shapes("blank").Visible = True
            Sheets("HARTLAND").Shapes("blank1").Visible = True
            Sheets("HARTLAND").Shapes("blank2").Visible = True
            Sheets("HARTLAND").Shapes("blank3").Visible = True
        Else
            Sheets("HARTLAND").Shapes("SHANNON_BURTON").Visible = False
        End If
        'JEREMY SOMMERS
        If Range("Employee_Select").value = "JEREMY SOMMERS" Then
            Sheets("HARTLAND").Shapes("JEREMY_SOMMERS").Visible = True
            Sheets("HARTLAND").Shapes("blank").Visible = True
            Sheets("HARTLAND").Shapes("blank1").Visible = True
            Sheets("HARTLAND").Shapes("blank2").Visible = True
            Sheets("HARTLAND").Shapes("blank3").Visible = True
        Else
            Sheets("HARTLAND").Shapes("JEREMY_SOMMERS").Visible = False
        End If
        'KEN MUELLER
        If Range("Employee_Select").value = "KEN MUELLER" Then
            Sheets("HARTLAND").Shapes("KEN_MUELLER").Visible = True
            Sheets("HARTLAND").Shapes("blank").Visible = True
            Sheets("HARTLAND").Shapes("blank1").Visible = True
            Sheets("HARTLAND").Shapes("blank2").Visible = True
            Sheets("HARTLAND").Shapes("blank3").Visible = True
        Else
            Sheets("HARTLAND").Shapes("KEN_MUELLER").Visible = False
        End If
        'ANDREW WOJDYLA
        If Range("Employee_Select").value = "ANDREW WOJDYLA" Then
            Sheets("HARTLAND").Shapes("ANDREW_WOJDYLA").Visible = True
            Sheets("HARTLAND").Shapes("blank").Visible = True
            Sheets("HARTLAND").Shapes("blank1").Visible = True
            Sheets("HARTLAND").Shapes("blank2").Visible = True
            Sheets("HARTLAND").Shapes("blank3").Visible = True
        Else
            Sheets("HARTLAND").Shapes("ANDREW_WOJDYLA").Visible = False
        End If
        'DAVID KLISH
        If Range("Employee_Select").value = "DAVID KLISH" Then
            Sheets("HARTLAND").Shapes("DAVID_KLISH").Visible = True
            Sheets("HARTLAND").Shapes("blank").Visible = True
            Sheets("HARTLAND").Shapes("blank1").Visible = True
            Sheets("HARTLAND").Shapes("blank2").Visible = True
            Sheets("HARTLAND").Shapes("blank3").Visible = True
        Else
            Sheets("HARTLAND").Shapes("DAVID_KLISH").Visible = False
        End If
        'BOB KRAMER
        If Range("Employee_Select").value = "BOB KRAMER" Then
            Sheets("HARTLAND").Shapes("BOB_KRAMER").Visible = True
            Sheets("HARTLAND").Shapes("blank").Visible = True
            Sheets("HARTLAND").Shapes("blank1").Visible = True
            Sheets("HARTLAND").Shapes("blank2").Visible = True
            Sheets("HARTLAND").Shapes("blank3").Visible = True
        Else
            Sheets("HARTLAND").Shapes("BOB_KRAMER").Visible = False
        End If
        If Range("Employee_Select").value = "Show objects" Then
            Sheets("HARTLAND").Shapes("blank").Visible = False
            Sheets("HARTLAND").Shapes("blank1").Visible = False
            Sheets("HARTLAND").Shapes("blank2").Visible = False
            Sheets("HARTLAND").Shapes("blank3").Visible = False
        End If
    '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    
    End Sub

  2. #2
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    48,146

    Re: Code unable to debug, how to run continuously?

    Put the word Stop as the first line of code in the Change event handler. Then, when you make a change, it will stop and you can use F8 to step through the code.

    Regards, TMS
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


  3. #3
    Registered User
    Join Date
    06-10-2015
    Location
    USA
    MS-Off Ver
    2013
    Posts
    37

    Re: Code unable to debug, how to run continuously?

    TMS,

    If I put the word stop there, will this run continuously? I basically need this running in the background at all times so when the selection is made, it will still update. Could explain more as to where the "change event handler is"?
    Thanks for the help.

  4. #4
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    48,146

    Re: Code unable to debug, how to run continuously?

    Private Sub Worksheet_Change(ByVal Target As Range)
        Dim Employee_select As String
    
    Stop             ' for diagnostic purposes.
    
    ' rest of code
    ' vvvvv
    If you have a Worksheet Change event handler, such as your code, it will fire for EVERY change made on the worksheet. It's then up to you to decide whether or not you are interested in the change that has been made. And, if you are, what do you want to do about it.

    So, yes, the Worksheet Change event handler will (does) run continuously but, for diagnostic purposes, the Stop statement will halt execution so that you can step through and see what is happening. However, what IS happening is that for each and every change made to ANY cell on the worksheet, the event will fire and check the values of certain Named Ranges. It will then hide or unhide specific rows.

    The code looks a little repetitive and not very scaleable but I'm sure it does what you want.

    Regards, TMS

  5. #5
    Registered User
    Join Date
    06-10-2015
    Location
    USA
    MS-Off Ver
    2013
    Posts
    37

    Re: Code unable to debug, how to run continuously?

    Thank you so much, you've seriously been so much help, thanks for explaining it to me. I managed to get it working, do I have a clue how? Absolutely not. It just started working for some reason and I don't even know what I changed. The explanation you gave was very thorough though and I appreciate that, keep up the good work!

  6. #6
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    48,146

    Re: Code unable to debug, how to run continuously?

    You're welcome. Thanks for the rep.



    If you are satisfied with the solution(s) provided, please mark your thread as Solved.


    New quick method:
    Select Thread Tools-> Mark thread as Solved. To undo, select Thread Tools-> Mark thread as Unsolved.

    Or you can use this way:

    How to mark a thread Solved
    Go to the first post
    Click edit
    Click Go Advanced
    Just below the word Title you will see a dropdown with the word No prefix.
    Change to Solved
    Click Save


    You may also want to consider thanking those people who helped you by clicking on the little star at the bottom left of their reply to your question.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Error in the code please debug it
    By kalyaaans in forum Hello..Introduce yourself
    Replies: 1
    Last Post: 09-22-2014, 10:28 AM
  2. Coming a debug "unable to get the OLEObjects property of the worksheet class
    By HaroonSid in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 05-07-2014, 02:33 AM
  3. VBA Code Runs in Debug Mode But Returns Type Mismatch Error Outside Debug Mode
    By valerie.k.chiang in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 01-24-2014, 03:48 PM
  4. [SOLVED] Debug: How to debug this code?
    By reach78 in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 09-25-2013, 07:16 AM
  5. [SOLVED] Runtime error...53; unable to debug
    By vinay.kottur in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 02-11-2013, 01:34 PM
  6. Debug the Code
    By macrogeek in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 10-17-2011, 06:45 AM
  7. HELP, trying to debug this code...
    By twofootgiant in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-18-2011, 12:05 PM

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