+ Reply to Thread
Results 1 to 14 of 14

Adding X Columns for user input based on value of one cell

  1. #1
    Registered User
    Join Date
    09-16-2013
    Location
    Burlington, Ontario, Canada
    MS-Off Ver
    Excel 2007
    Posts
    18

    Adding X Columns for user input based on value of one cell

    I have a spreadsheet to enter in data for new users to be added to a system. Depending on the value the entered in C3, I would like the spreadsheet to add additional columns added to the spreadsheet to correspond to the value in C3.

    The minimum value of C3=1 and maximum value is 10. Default value is 1. Therefore, one column beginning at C5 will always be present for one users data. If C3=5, I would like 4 additional columns identical to the one beginning at C5 to be inserted in D5, E5, etc.

    The header for column C5 has text "User Input #1". I would like additional columns to have the header User Input #X where X is a sequential value up to the value indicated in C3.

    Can anyone offer any help with this? I am fairly novice with complex macros.

    Thanks!

  2. #2
    Forum Contributor
    Join Date
    09-11-2013
    Location
    Huntsville, AL
    MS-Off Ver
    Excel 2007
    Posts
    180

    Re: Adding X Columns for user input based on value of one cell

    It would be nice to see an example.

  3. #3
    Registered User
    Join Date
    09-16-2013
    Location
    Burlington, Ontario, Canada
    MS-Off Ver
    Excel 2007
    Posts
    18

    Re: Adding X Columns for user input based on value of one cell

    Here's a sample. I would like columns beginning in D5-L5 to appear/disappear pending the value of C3. Maximum value of C3=10, minimum value=1.

    Thanks.
    Attached Files Attached Files

  4. #4
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 365 on Win11 (desktop), 2019 on Win11 (notebook)
    Posts
    8,199

    Re: Adding X Columns for user input based on value of one cell

    Hi, reluctantresearch,

    save the workbook as a macro enabled workbook, right click on the worksheet tab, choose View Code, enter the code into the code window:

    Please Login or Register  to view this content.
    Ciao,
    Holger
    Use Code-Tags for showing your code: [code] Your Code here [/code]
    Please mark your question Solved if there has been offered a solution that works fine for you

  5. #5
    Registered User
    Join Date
    09-16-2013
    Location
    Burlington, Ontario, Canada
    MS-Off Ver
    Excel 2007
    Posts
    18

    Re: Adding X Columns for user input based on value of one cell

    Thanks!! It works exactly how I wanted it to.

  6. #6
    Registered User
    Join Date
    09-16-2013
    Location
    Burlington, Ontario, Canada
    MS-Off Ver
    Excel 2007
    Posts
    18

    Re: Adding X Columns for user input based on value of one cell

    Hi there. I have a new requirement for this sheet now.

    Users are asking me if I can remove cells B8-B24. A simple delete and shift cells left messes up the functionality. Can anyone help with this little tweak?

    Thanks!

  7. #7
    Forum Expert Fotis1991's Avatar
    Join Date
    10-11-2011
    Location
    Athens(The homeland of the Democracy!). Greece
    MS-Off Ver
    Excel 1997!&2003 & 2007&2010
    Posts
    13,744

    Re: Adding X Columns for user input based on value of one cell

    This is a different requirement and you have to start a new thread for this.

    So pls:

    As that takes care of your original question, please select Thread Tools from the menu link above and mark this thread as SOLVED,as per Forum Rule #9. Thank you.

    Also, as a new member of the forum, you may not be aware that you can thank those who have helped you by clicking the small star icon located in the lower left corner of the post in which the help was given. By doing so you can add to the reputation(s) of those who helped.
    Regards

    Fotis.

    -This is my Greek whisper to Europe.

    --Remember, saying thanks only takes a second or two. Click the little star * below, to give some Rep if you think an answer deserves it.

    Advanced Excel Techniques: http://excelxor.com/

    --KISS(Keep it simple Stupid)

    --Bring them back.

    ---See about Acropolis of Athens.

    --Visit Greece.

  8. #8
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 365 on Win11 (desktop), 2019 on Win11 (notebook)
    Posts
    8,199

    Re: Adding X Columns for user input based on value of one cell

    Hi, reluctantresearch,

    thereīs a glitch in just deleting a part of the data as you told. Option 1 would be to hide the entire column B which would leave the code intact. If you want to delete data why only rows 8 to 24 and what is to be found in rows 25 to 32? If the latter part is to be moved as well just the basic cell would be left intact while the rest of the code shifts one column to the left. As there is now way to split up the column into only a couple of rows to be partly visible you may have to take a different road to get to the result you want to reach (which isnīt really clear to me from the description).

    @Fotis1991:
    I think the explanation still belongs here. If itīs really only a part of a column that needs to be made visible I agree with you: that should be covered within a new thread because it would need a different code to do so.

    Holger

  9. #9
    Registered User
    Join Date
    09-16-2013
    Location
    Burlington, Ontario, Canada
    MS-Off Ver
    Excel 2007
    Posts
    18

    Re: Adding X Columns for user input based on value of one cell

    Hi Holger. Thanks for the response.

    I am okay with deleting all of column B from row 8-32 - I don't need those cells at all.
    The "Additional Information" is no longer needed and we won't use it in the future but I want to maintain the functionality of adding user input columns dependant on value in C3.

    Does this make it any easier?

  10. #10
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 365 on Win11 (desktop), 2019 on Win11 (notebook)
    Posts
    8,199

    Re: Adding X Columns for user input based on value of one cell

    Hi, reluctant research,

    after deletion of that part change the code to
    Please Login or Register  to view this content.
    If you choose 1 you will notice that you will have to delete cells L4:L5 as well.

    Ciao,
    Holger

  11. #11
    Registered User
    Join Date
    09-16-2013
    Location
    Burlington, Ontario, Canada
    MS-Off Ver
    Excel 2007
    Posts
    18

    Re: Adding X Columns for user input based on value of one cell

    So close! It almost works, but I need C2 & C3 to remain visible when C3=1. Currently, they disappear if C3=1.

    Would it be easier if the text and dropdown in C2 and C3 were moved to a different location like A5 & B5?

  12. #12
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 365 on Win11 (desktop), 2019 on Win11 (notebook)
    Posts
    8,199

    Re: Adding X Columns for user input based on value of one cell

    Hi, reluctantresearch,

    indeed the cell to monitor should be located in either Column A or B (rows may be as you please).

    Ciao,
    Holger

  13. #13
    Registered User
    Join Date
    09-16-2013
    Location
    Burlington, Ontario, Canada
    MS-Off Ver
    Excel 2007
    Posts
    18

    Re: Adding X Columns for user input based on value of one cell

    Thanks so much Holger. Got a little tied up with other things here at work but I am going to work with this again tomorrow and let you know the results.

    Thanks again! Matt

  14. #14
    Registered User
    Join Date
    09-16-2013
    Location
    Burlington, Ontario, Canada
    MS-Off Ver
    Excel 2007
    Posts
    18

    Re: Adding X Columns for user input based on value of one cell

    Hey Holger. I did some more fiddling around with the arrangement of the sheet and moved the quantity selection over to column B. Then modified the code to start a couple rows lower and it worked perfectly.

    Thanks again for all of your help and advice. Reputation added again

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Finding cell based on user input within a calendar
    By rcoolb2002 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 09-13-2013, 04:04 AM
  2. Cell based on formula and allow user input?
    By proepert in forum Excel Formulas & Functions
    Replies: 8
    Last Post: 06-27-2013, 06:00 PM
  3. [SOLVED]Hide Rows and Columns Based on User Input
    By thesteve in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 01-31-2013, 01:32 PM
  4. placing a cell value based on user input
    By JJCRIC in forum Excel General
    Replies: 2
    Last Post: 12-29-2009, 10:03 PM
  5. How to reference a cell based on user input?
    By ChromiumBlue in forum Excel - New Users/Basics
    Replies: 4
    Last Post: 12-14-2006, 11:39 AM

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