+ Reply to Thread
Results 1 to 9 of 9

Application.Inputbox

Hybrid View

  1. #1
    Forum Contributor
    Join Date
    02-22-2011
    Location
    South Africa
    MS-Off Ver
    Excel 2010
    Posts
    108

    Application.Inputbox

    Hi Masters

    I want to use an Application InPutBox that will ask the users to enter a password.
    When the inputbox is = 0 and they press ok they should get a msgbox that tells them you should enter a password to continue.
    When they press Cancel the Inputbox stop and not give me the same msgbox as mentioned above.

    Any help will do?

    Thanks and regards,
    Hilton

  2. #2
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,481

    Re: Application.Inputbox

    Sub X()
    
        Dim vntAnswer As Variant
        Dim lngAttempt As Long
        
        Do
            vntAnswer = Application.InputBox("Password")
            If vntAnswer = False Then Exit Sub
            
            lngAttempt = lngAttempt + 1
            If lngAttempt > 2 Then
                MsgBox "Too many tries", vbExclamation
                Exit Sub
            End If
            
        Loop While Len(vntAnswer) = 0
        
        MsgBox "Password is " & vntAnswer
        
        
    End Sub
    Cheers
    Andy
    www.andypope.info

  3. #3
    Forum Contributor
    Join Date
    02-22-2011
    Location
    South Africa
    MS-Off Ver
    Excel 2010
    Posts
    108

    Re: Application.Inputbox

    Hi Andy,

    Thank you for the Code it is working 100%.
    Can you add the following step to the code if possible?

    If the password is = 1010 Then
    Run "Macro"
    If Password <> 1010 Then
    Msgbox = "incorrect password Retry or cancel", vbRetryCancel
    If response = Retry
    Goto Start
    Else Exit Sub

  4. #4
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,481

    Re: Application.Inputbox

    Sub X()
    
        Dim vntAnswer As Variant
        Const PWD = "1010"
        
            
        Do
            vntAnswer = Application.InputBox("Password")
            If vntAnswer = False Then Exit Sub
            
            If vntAnswer = PWD Then
                MsgBox "Go run my macro"
                Exit Sub
            End If
            
        Loop While MsgBox("Incorrect password Retry or Cancel", vbRetryCancel) = vbRetry
        
        
    End Sub

  5. #5
    Forum Contributor
    Join Date
    02-22-2011
    Location
    South Africa
    MS-Off Ver
    Excel 2010
    Posts
    108

    Re: Application.Inputbox

    Thanks a million problem solved and now i can make the existing codes a lot shorter with this formality...

  6. #6
    Forum Contributor
    Join Date
    02-22-2011
    Location
    South Africa
    MS-Off Ver
    Excel 2010
    Posts
    108

    Re: Application.Inputbox

    Please help me with a easy code that will copy and paste data in the next empty row.

    I have data fulled on the "Input" sheet then the macro copy and paste that onto to the record sheet however I want that to be copied everytime in the next empty row?

  7. #7
    Forum Guru Winon's Avatar
    Join Date
    02-20-2007
    Location
    East Rand, R.S.A.
    MS-Off Ver
    2010
    Posts
    6,113

    Re: Application.Inputbox

    Hello Hilton1982,

    Your last Post is way off the topic Re: Application.Inputbox. You should by right start a new thread.

    Do you want to copy within the same sheet or from one to another?
    Please consider:

    Be polite. Thank those who have helped you. Then Click on the star icon in the lower left part of the contributor's post and add Reputation. Cleaning up when you're done. If you are satisfied with the help you have received, then Please do Mark your thread [SOLVED] .

  8. #8
    Forum Contributor
    Join Date
    02-22-2011
    Location
    South Africa
    MS-Off Ver
    Excel 2010
    Posts
    108

    Re: Application.Inputbox

    Winon from one to another

    Sorry I will open a new Tread next time...

    Thanks

  9. #9
    Forum Guru Winon's Avatar
    Join Date
    02-20-2007
    Location
    East Rand, R.S.A.
    MS-Off Ver
    2010
    Posts
    6,113

    Re: Application.Inputbox

    This is the basics which should give you a start to tweak it the way you want it.

    Sub Test()
    
    Dim LR As Long
    Dim r As Long
    
    LR = Cells(Rows.Count, "A").End(xlUp).Row
        
    Range("A2:A1000").EntireRow.Copy _
        Sheets("Sheet2").Range("A" & Sheets("Sheet2").Rows.Count).End(xlUp).Offset(1)
    
    
    End Sub

+ Reply to Thread

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