+ Reply to Thread
Results 1 to 5 of 5

Need help with input box

  1. #1
    Brad
    Guest

    Need help with input box

    Alright, I have code that will have the user insert a Contract # into a
    specific cell. This works fine. But what I would like to know, is it possible
    to have the inputbox message to already have the Cells Value Listed, then the
    user would insert the new information only if neccessary. For Example:

    Cell A1 would have the contract # "123" already listed. The inputbox would
    ask the user "Please Enter Contract # or if this is the Correct # then press
    OK". But in the area where the user enters the information, the "123" would
    already be listed. Can this be done with a Inputbox? I hope this makes sense.
    Any help is appreciated. Here is the code that I have.

    Dim ans As Variant
    ans = InputBox("Please Enter Contract # or if this is the Correct # then
    press OK")
    With Worksheets("Agreement")
    Cells(8, 12) = (ans)
    End With



  2. #2
    Forum Contributor
    Join Date
    11-16-2004
    Posts
    282

    Input box default value

    See changes in your code in BOLD below (change "InputBox Title" to your own title for the input box and change the cell reference A1 to your own):

    Dim ans As Variant
    ans = InputBox("Please Enter Contract # or if this is the Correct # then
    press OK", "InputBox Title" , ActiveSheet.Range("A1").Value)
    With Worksheets("Agreement")
    Cells(8, 12) = (ans)
    End With

    Hope this helps,
    theDude

  3. #3
    JE McGimpsey
    Guest

    Re: Need help with input box

    One way:

    Dim ans As Variant
    Do
    ans = Application.InputBox( _
    Prompt:="Please Enter Contract #", _
    Default:=Sheets("Agreement").Range("A1").Value, _
    Title:="Contract Number", _
    Type:=2)
    If ans = False Then Exit Sub 'User cancelled
    Loop Until Len(ans) > 0


    In article <[email protected]>,
    "Brad" <[email protected]> wrote:

    > Alright, I have code that will have the user insert a Contract # into a
    > specific cell. This works fine. But what I would like to know, is it possible
    > to have the inputbox message to already have the Cells Value Listed, then the
    > user would insert the new information only if neccessary. For Example:
    >
    > Cell A1 would have the contract # "123" already listed. The inputbox would
    > ask the user "Please Enter Contract # or if this is the Correct # then press
    > OK". But in the area where the user enters the information, the "123" would
    > already be listed. Can this be done with a Inputbox? I hope this makes sense.
    > Any help is appreciated. Here is the code that I have.
    >
    > Dim ans As Variant
    > ans = InputBox("Please Enter Contract # or if this is the Correct # then
    > press OK")
    > With Worksheets("Agreement")
    > Cells(8, 12) = (ans)
    > End With


  4. #4
    JulieD
    Guest

    Re: Need help with input box

    Hi Brad

    yes, basically the third parameter of the inputbox is a default answer

    so you can do something like this:

    Sheets("Agreement").Cells(8, 12).Value = InputBox("Please Enter Contract #
    or if this is the Correct # then press OK", , Sheets("Agreement").Cells(8,
    12).Value)


    (all on one line)

    Cheers
    julieD



    "Brad" <[email protected]> wrote in message
    news:[email protected]...
    > Alright, I have code that will have the user insert a Contract # into a
    > specific cell. This works fine. But what I would like to know, is it
    > possible
    > to have the inputbox message to already have the Cells Value Listed, then
    > the
    > user would insert the new information only if neccessary. For Example:
    >
    > Cell A1 would have the contract # "123" already listed. The inputbox would
    > ask the user "Please Enter Contract # or if this is the Correct # then
    > press
    > OK". But in the area where the user enters the information, the "123"
    > would
    > already be listed. Can this be done with a Inputbox? I hope this makes
    > sense.
    > Any help is appreciated. Here is the code that I have.
    >
    > Dim ans As Variant
    > ans = InputBox("Please Enter Contract # or if this is the Correct #
    > then
    > press OK")
    > With Worksheets("Agreement")
    > Cells(8, 12) = (ans)
    > End With
    >
    >




  5. #5
    Paul B
    Guest

    Re: Need help with input box

    Brad, do you want the valve in the active cell in the input box? if so try
    this

    ans = InputBox("Please Enter Contract # or if this is the Correct # then
    press OK", , ActiveCell)

    --
    Paul B
    Always backup your data before trying something new
    Please post any response to the newsgroups so others can benefit from it
    Feedback on answers is always appreciated!
    Using Excel 2002 & 2003

    "Brad" <[email protected]> wrote in message
    news:[email protected]...
    > Alright, I have code that will have the user insert a Contract # into a
    > specific cell. This works fine. But what I would like to know, is it
    > possible
    > to have the inputbox message to already have the Cells Value Listed, then
    > the
    > user would insert the new information only if neccessary. For Example:
    >
    > Cell A1 would have the contract # "123" already listed. The inputbox would
    > ask the user "Please Enter Contract # or if this is the Correct # then
    > press
    > OK". But in the area where the user enters the information, the "123"
    > would
    > already be listed. Can this be done with a Inputbox? I hope this makes
    > sense.
    > Any help is appreciated. Here is the code that I have.
    >
    > Dim ans As Variant
    > ans = InputBox("Please Enter Contract # or if this is the Correct #
    > then
    > press OK")
    > With Worksheets("Agreement")
    > Cells(8, 12) = (ans)
    > End With
    >
    >




+ 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