+ Reply to Thread
Results 1 to 21 of 21

Setting up input box

Hybrid View

  1. #1
    Registered User
    Join Date
    06-09-2009
    Location
    Australia
    MS-Off Ver
    Excel 2007
    Posts
    88

    Setting up input box

    What I want to be able to do is set up a thing that when you're in the excel sheet you click on it. Up comes a box where you can enter data and when you click submit. It puts that data back into excel spreadsheet. I have attached a spreadsheet to show what I mean. I have deleted some stuff that are unnecessary so don't worry about them.

    What I need is for you to click a button that will create a new row/copy into the next row, from A9-AH9. Then the button will automatically bring up a box that will ask for Time, Timber, Clay, Iron, Warehouse, Hiding Place and then will enter that data into there respective cells which would be D20, F20, I20, L20, O20, Q20 respectively. That is the main idea. maybe it would be better to have te button come up with a box asking for the information and then will create the row and insert the data. If it's easier you can just do the box with just time or something so it's easier. I can then do the rest.

    Tyvm. This to me seems really complicated so not sure how you would do this at all. i've looked at other stuff on the internet but haven't gotten anywhere.

    P.S. If you have a more generic thing similar to this then show me the code for that or upload it and I can change it too suite my needs.

    ty again
    Last edited by dextras; 06-22-2009 at 08:01 AM.

  2. #2
    Registered User
    Join Date
    06-09-2009
    Location
    Australia
    MS-Off Ver
    Excel 2007
    Posts
    88

    Re: Setting up input box

    Here's the attachment. Forgot to attach
    Attached Files Attached Files

  3. #3
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: Setting up input box

    You can use a Button to fire the event, the event would as you say invoke various InputBoxes - if you use Application.InputBox (see: http://msdn.microsoft.com/en-us/libr...ffice.11).aspx) you can further restrict the type of info that can be entered into the dialog so as to lessen the amount of validation you need to do with the resulting value... thereafter it's case of pasting the results to the next available row...

    A very basic example as proof of concept:

    Public Sub CaptureInput()
    Dim vResponses(1 To 2) As Variant
    vResponses(1) = Application.InputBox("Enter a Word", "Word Entry", "", Type:=2)
    vResponses(2) = Application.InputBox("Enter a Number", "Number Entry", "", Type:=1)
    If IsNumeric(Application.Match(False, vResponses, 0)) Then
        MsgBox "Not All Entries Complete - Action Cancelled", vbCritical, "Incomplete"
    Else
        With Cells(Rows.Count, "D").End(xlUp).Offset(1)
            .Value = vResponses(1)
            .Offset(, 1).Value = vResponses(2)
        End With
    End If
    End Sub

  4. #4
    Registered User
    Join Date
    06-09-2009
    Location
    Australia
    MS-Off Ver
    Excel 2007
    Posts
    88

    Re: Setting up input box

    Sorry for stupidity but how do I use this. How do I use the code specifically?

  5. #5
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: Setting up input box

    How you invoke the routine will in part depend on the button control you opt to use... if you use a Forms button you would assign the Sub Routine to the Button (via Right Click -> Assign Macro), if you opt for an ActiveX button you could either a) change the routine to become the actual Click event for the ActiveX button itself (the code would reside in the Sheet object on which the Button exists) or b) use the Click event to Call this Routine - option b) would mean you could easily call the Routine in different ways - either manually (F8 or via VBE) or via the Button click event. Is that what you meant ?

    I got the impression from the penultimate line in your original post that you were happy to nurdle the code to do what you wanted once you had a rough idea as to how to go about it... I always think that's the best approach to adopt as it generally aids the learning process (or at least that's what I find myself).

    Let me/us know if there are other issues that need to be resolved.

  6. #6
    Registered User
    Join Date
    06-09-2009
    Location
    Australia
    MS-Off Ver
    Excel 2007
    Posts
    88

    Re: Setting up input box

    Sorry, I kinda don't get this at all. Can you walk me through the process of this. I've looked at that website but am confused. I'm not sre where I would put the Application.InputBox code. I'm new to VB so don't understand at all. If you can maybe create this in an excel document/ the one I attached and then I think I can look at it and figure it out from there. It would just need to be done for like one input as such. ty

+ 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