+ Reply to Thread
Results 1 to 21 of 21

Setting up input box

  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:

    Please Login or Register  to view this content.

  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

  7. #7
    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

    See attached

    Note in XL2007 if you have VBA in you would save as .xlsm rather than .xlsx
    Attached Files Attached Files

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

    Re: Setting up input box

    Looking at that, I see how you're doing it. Got a few questions though:
    1. How do I add another question as such? I tried this:
    Please Login or Register  to view this content.
    I know the 3's wrong (I think at least) but what do I use instead?

    2. How do I get it to paste the info into a predifined set of formulas in a new row. What I need is for it to paste the data into the thing I have in row 9 but in the new row. How can this be done?

    ty

  9. #9
    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

    Re: your first question...

    What you did was correct but you need to redefine the Variant Array vResponses from 1 to 2 to 1 to 3 ... ie tell the routine that the vResponses array is to contain 3 values.

    The reason I opted for an Array (not normal) was simply so that you could validate all Responses in one go such that if any were "Cancelled" (thereby returning False) the routine would terminate ... else you'd need to iterate each response one by one (or set up such that hitting Cancel was not viable but then you have no exit route)

    Re: your second question...

    don't follow... paste the info "into" formulas ?

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

    Re: Setting up input box

    What I have is that row in my document I attached above. In row 9. What I need is for that row to be pasted in the next row. (Ends up being row 20). Then you enter the information in the box which puts it in those cell. Those cells are ten referred to in cells that were pasted next door at the start.

    Hope that makes sense. ty

  11. #11
    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

    I'm heading offline but I suspect the below is along the lines of what you're after ?

    Please Login or Register  to view this content.

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

    Re: Setting up input box

    ^ Thank you, that worked perfectly. I have a few more questions though.

    1. How did you add your button? I have foiund out how to add one but I can't seem to be able to select yours or anything. Can't delete it. so how did you add it/how can i delete it?

    2. Is there a way for the macro to also copy the formatting across too? Like to copy the colours of the cells?

    3. I need to be able to protect the sheet so you can't edit it. Is there a way to do this with the macro still being able to run and be able to access what it needs?

    ty again

  13. #13
    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

    1. Adding Buttons - I used Active X button from the Control Toolbox Toolbar
    2. see revised example below
    3. lock the template cells (row 9), protect the sheet as normal - then use VBA to unprotect / protect the sheet (change strPwd to match your password, also password protect your VBA Project in the VB Editor)

    Please Login or Register  to view this content.

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

    Re: Setting up input box

    Alright, i've gotten step 1 and 2 to work. Step 3 works but doesn't do what I want.

    I can't figure out to do the protecting thing. What I need is this:

    1. To not allow users to unhide columns

    2. To allow users to edit the rows created by the macro

    3. To allow a user to use the macro whilst protected.

    The most important one is the last one

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

    Re: Setting up input box

    Nevermind. I figured out how to deal with that. I have one more question though. Is there a way to block a user from seeing a formula? In a cell that can be seen
    Last edited by dextras; 06-22-2009 at 03:03 AM.

  16. #16
    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

    When you Format cells there are two options on Protection tab namely:

    Locked
    Hidden

    if you check "hidden" then when the sheet is protected the Formulae in the cells you selected to hide will be hidden from the user.

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

    Re: Setting up input box

    ^ where's this sorry. Is this after you click protect sheet?

  18. #18
    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

    see section "how to hide formulas": http://www.online-tech-tips.com/ms-o...ulas-in-excel/

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

    Re: Setting up input box

    ^ Thank you. That will work. Another thing, I'm setting up a sexcod button and second module, that is also a CaptureInput. I tried:
    Please Login or Register  to view this content.
    Please Login or Register  to view this content.
    but that's wrong. How do you do it. How do you define 2 different captureinputs?

    ________________________________________________________________

    Another thing. How do I set up a macro to turn this:
    1,.4.1.+Ravenna,571,496,3884655,9190,0
    into this:
    1 .4.1.+Ravenna 571 496 3884655 9190 0
    Note: The spaces are seperate columns

    I know how to do this by using text to column and then having the seperator as a comma(,) but how do I do it as a macro. I then need to delete columns B,E,F,G and then:

    move column a to column b.

    Then:
    fill column A with
    Please Login or Register  to view this content.
    Sorry if that's a lot lol

  20. #20
    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

    Please keep a thread to a specific question - if you have other questions (ie TextToColumns/MacroRecorder) create additional thread(s) - if relevant post a link to this thread.

    Re: two buttons, without knowing what the 2nd is doing I would say it's likely you need two entirely separate routines, the names of which must be exclusive... ie

    CaptureInputA / CaptureInputB

    (remember to change the Click event to invoke the renamed Routine - ie instead of Call CaptureInput it should become Call CaptureInputA)

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

    Re: Setting up input box

    thank you that works. I think I've gotten my original question solved, so i'll edit and click solve but will ask other questions in new threads

+ 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