+ Reply to Thread
Results 1 to 11 of 11

Debug code

Hybrid View

  1. #1
    Forum Expert gmr4evr1's Avatar
    Join Date
    11-24-2014
    Location
    Texas
    MS-Off Ver
    Office 2010 and 2007
    Posts
    3,448

    Re: Debug code

    It shouldn't ask for the password twice. If someone enters the wrong password, it will exit the sub and not call the second sub. Try this
    Option Explicit
    
    Sub Refresh()
    
    Dim X As Variant
    Dim PW As String
    
    PW = InputBox("Please enter password below", "Password", "")
    
    If PW <> "SALARY" Then
            MsgBox "Incorrect Password"
            Exit Sub
    Else
    
    Application.ScreenUpdating = False
    Sheets("Finess-Actuals").Visible = True
    
    Sheets("Finess-Actuals").Select
    Range("A2:AL290").Select
    
    Sheets("Refresh & Upload").Select
    
    Sheets("Finess-Actuals").Visible = xlSheetVeryHidden
    Application.ScreenUpdating = True
    
    Call secondSub '<----- Your second sub name
    
    MsgBox "Your Budget Refresh is Complete!"
    
    End If
    
    End Sub
    1N73LL1G3NC3 15 7H3 4B1L17Y 70 4D4P7 70 CH4NG3 - 573PH3N H4WK1NG
    You don't have to add Rep if I have helped you out (but it would be nice), but please mark the thread as SOLVED if your issue is resolved.

    Tom

  2. #2
    Registered User
    Join Date
    10-14-2014
    Location
    USA
    MS-Off Ver
    2010
    Posts
    98

    Re: Debug code

    In the second sub, there is a line that is exactly the same as the one in the first sub and it starts with "if PW..."

    Should I erase it ?

    Quote Originally Posted by gmr4evr1 View Post
    It shouldn't ask for the password twice. If someone enters the wrong password, it will exit the sub and not call the second sub. Try this
    Option Explicit
    
    Sub Refresh()
    
    Dim X As Variant
    Dim PW As String
    
    PW = InputBox("Please enter password below", "Password", "")
    
    If PW <> "SALARY" Then
            MsgBox "Incorrect Password"
            Exit Sub
    Else
    
    Application.ScreenUpdating = False
    Sheets("Finess-Actuals").Visible = True
    
    Sheets("Finess-Actuals").Select
    Range("A2:AL290").Select
    
    Sheets("Refresh & Upload").Select
    
    Sheets("Finess-Actuals").Visible = xlSheetVeryHidden
    Application.ScreenUpdating = True
    
    Call secondSub '<----- Your second sub name
    
    MsgBox "Your Budget Refresh is Complete!"
    
    End If
    
    End Sub

+ 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. 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
  3. [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
  4. [SOLVED] VBA Code Debug Error
    By Jennsy in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 12-19-2012, 08:55 AM
  5. Problem trying to debug some code
    By Exadore in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 12-07-2011, 05:28 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