Consulting

Results 1 to 4 of 4

Thread: Input Box Help

  1. #1
    VBAX Regular dub's Avatar
    Joined
    Nov 2010
    Location
    Boulder, CO
    Posts
    18
    Location

    Input Box Help

    Hi,
    I need code for an input box that uses a variable name in the prompt.
    I would like it to look like this...
    Title: Please provide initials
    Msg: The system does not have initials for the user name "user name variable here". Please provide your initials for the purpose of tracking edits. Thank you.

    Would like "ok" and "cancel" button. If cancel is pressed would like the following msg: You must provide you initials to continue.
    This msg I would like "ok" button and "close program" button and if the close program button is pushed I would like the current workbook to close.

    I already have code to get the user name and to make this get initials sub run upon opening the workbook.
    Thanks a bunch!!
    </IMG>
    Dub

  2. #2
    VBAX Regular dub's Avatar
    Joined
    Nov 2010
    Location
    Boulder, CO
    Posts
    18
    Location
    I have been working on the fore mentioned but I'm having some problems.
    Here is the code I have so far
    [vba]Private Sub Workbook_Open()
    Initials
    End Sub
    Sub Initials()
    Dim iRow As Integer, Initials As String, UserName As String, myForm As UserForm, vbCancel As String
    UserName = Environ("USERNAME")

    If WorksheetFunction.CountIf(Columns("A"), UserName) >= 1 Then
    Else
    Retry:
    Initials = InputBox("The system does not have initials " & _
    "for the user name " & UserName & "." & " Please provide your " & _
    "initials for the purpose of tracking edits. Thank you.", "Please provide initials")
    If Initials = vbCancel Then
    Set myForm = New myForm
    Load myForm
    myForm.Show


    End If
    Cells(iRow + 1, 1).Select
    ActiveCell.Value = UserName
    ActiveCell.Offset(rowoffset:=0, columnoffset:=1).Value = Initials
    End If

    ExitProgram:
    End Sub

    [/vba]
    I am getting an error for "ire.Show" that says object or property not supported.

    My other problem is I can't figure out how to use the code for the buttons to go to a specific line in the main workbook code, shown about. I have two buttons: Retry and Exit Program. when exit program is pushed I want to go to a line in the main code that will close the current workbook; if Retry is pushed I want to go to the line Retry: in the above code.
    Any help is appreciated Thanks!
    Dub

  3. #3
    VBAX Guru mancubus's Avatar
    Joined
    Dec 2010
    Location
    "Where I lay my head is home" :D
    Posts
    2,644
    you may play around with this:

    [vba]
    Sub InputBoxExample()
    'http://www.mrexcel.com/forum/showthread.php?t=35206
    Dim Initials As Variant, UserName As String

    UserName = Environ("USERNAME")

    showInputBox:
    Initials = Application.InputBox("System does not have initials for the user name " _
    & UserName & ". Please provide your initials for the purpose of tracking edits." _
    & " Thank you.", "Please provide Initials")
    If Initials = False Then
    MsgBox "You must provide your Initials to continue.", 48 + 1, vbOKCancel, "Cancel was clicked."
    Exit Sub
    ElseIf Initials = "" Then
    MsgBox "You must click Cancel to exit.", 48, "You clicked Ok but entered nothing."
    GoTo showInputBox
    Else
    MsgBox "You entered " & Initials & ".", 64, "Please click OK to resume."
    End If
    End Sub[/vba]
    Last edited by mancubus; 06-13-2011 at 11:25 PM.
    PLS DO NOT PM; OPEN A THREAD INSTEAD!!!

    1) Posting Code
    [CODE]PasteYourCodeHere[/CODE]
    (or paste your code, select it, click # button)

    2) Uploading File(s)
    Go Advanced / Attachments - Manage Attachments / Add Files / Select Files / Select the file(s) (multiple files can be selected while holding Ctrl key) / Upload Files / Done
    Replace company specific / sensitive / confidential data. Include so many rows and sheets etc in the uploaded workbook to enable the helpers visualize the data and table structure. Helpers do not need the entire workbook.

    3) Testing the Codes
    always back up your files before testing the codes.

    4) Marking the Thread as Solved
    from Thread Tools (on the top right corner, above the first message)

  4. #4
    VBAX Guru mancubus's Avatar
    Joined
    Dec 2010
    Location
    "Where I lay my head is home" :D
    Posts
    2,644
    ps:
    48 +1 (or 49) = vbExclamation + vbOKCancel
    PLS DO NOT PM; OPEN A THREAD INSTEAD!!!

    1) Posting Code
    [CODE]PasteYourCodeHere[/CODE]
    (or paste your code, select it, click # button)

    2) Uploading File(s)
    Go Advanced / Attachments - Manage Attachments / Add Files / Select Files / Select the file(s) (multiple files can be selected while holding Ctrl key) / Upload Files / Done
    Replace company specific / sensitive / confidential data. Include so many rows and sheets etc in the uploaded workbook to enable the helpers visualize the data and table structure. Helpers do not need the entire workbook.

    3) Testing the Codes
    always back up your files before testing the codes.

    4) Marking the Thread as Solved
    from Thread Tools (on the top right corner, above the first message)

Posting Permissions

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