+ Reply to Thread
Results 1 to 19 of 19

Userform Textboxes and Comboboxes to Populate certain cells across 100 columnsx1colatatime

  1. #1
    Registered User
    Join Date
    09-30-2018
    Location
    Australia
    MS-Off Ver
    Excel 2013
    Posts
    9

    Userform Textboxes and Comboboxes to Populate certain cells across 100 columnsx1colatatime

    Hi All, Im a vba code stealing/altering noob that is propbably on the wrong track...?

    I'm trying to figure out how to use command button click on a userform to transfer textbox and combobox data into specific cells across 100 columns - 1 column at a time. not every cell will contain data on every command click hence needing to be in specific cells and not find next cell or next column item.

    The userform needs to re-set and next column selection begin up until a quantity is reached (quantity is in Cell B22)

    Can anybody please point me in the right direction?

    Cheers in advance


    Private Sub CommandButton3_Click()
    Dim i As Integer
    For i = 3 To 103
    Dim ws As Worksheets
    Set ws = Worksheets("Frame Input")
    With ws
    .Cells(C23, i).Value = TextBox5.Text
    .Cells(C25, i).Value = TextBox3.Text
    .Cells(C28, i).Value = ComboBox1.Text
    .Cells(C29, i).Value = TextBox1.Text
    .Cells(C30, i).Value = TextBox2.Text
    .Cells(C24, i).Value = ComboBox19.Text
    .Cells(C31, i).Value = ComboBox4.Text
    .Cells(C39, i).Value = ComboBox2.Text
    .Cells(C51, i).Value = ComboBox3.Text
    .Cells(C35, i).Value = ComboBox24.Text
    .Cells(C32, i).Value = ComboBox25.Text
    .Cells(C63, i).Value = ComboBox5.Text
    .Cells(C115, i).Value = ComboBox7.Text
    .Cells(C167, i).Value = ComboBox8.Text
    .Cells(C371, i).Value = ComboBox15.Text + " " + ComboBox16.Text
    .Cells(C323, i).Value = ComboBox12.Text
    .Cells(C347, i).Value = ComboBox13.Value
    .Cells(C378, i).Value = ComboBox14.Text
    .Cells(C385, i).Value = ComboBox26.Text
    .Cells(C392, i).Value = ComboBox17.Text + " " + ComboBox18.Text
    .Cells(C219, i).Value = ComboBox9.Text
    .Cells(C271, i).Value = ComboBox10.Text
    .Cells(C471, i).Value = ComboBox11.Text
    .Cells(C472, i).Value = ComboBox20.Text
    .Cells(C473, i).Value = ComboBox21.Text
    .Cells(C474, i).Value = ComboBox22.Text
    .Cells(C475, i).Value = ComboBox23.Text
    End With
    Next i

    End Sub

  2. #2
    Forum Expert mikerickson's Avatar
    Join Date
    03-30-2007
    Location
    Davis CA
    MS-Off Ver
    Excel 2011
    Posts
    6,229

    Re: Userform Textboxes and Comboboxes to Populate certain cells across 100 columnsx1colata

    Rather than looping, you could use code like
    Please Login or Register  to view this content.
    _
    ...How to Cross-post politely...
    ..Wrap code by selecting the code and clicking the # or read this. Thank you.

  3. #3
    Forum Guru Kyle123's Avatar
    Join Date
    03-10-2010
    Location
    Leeds
    MS-Off Ver
    365 Win 11
    Posts
    7,238

    Re: Userform Textboxes and Comboboxes to Populate certain cells across 100 columnsx1colata

    It may also be worth revising your structure, if you have 100 columns that don't always need populating, then there may be a better way of laying out your workbook

  4. #4
    Registered User
    Join Date
    09-30-2018
    Location
    Australia
    MS-Off Ver
    Excel 2013
    Posts
    9
    Quote Originally Posted by Kyle123 View Post
    It may also be worth revising your structure, if you have 100 columns that don't always need populating, then there may be a better way of laying out your workbook
    Yeah since dipping my toes into vba I’m finding I have to revise layouts to suit easily written codes however with this on each item is a column and the components in each item are the cells it would be 6 in one or half dozen in the other by switching them - unless I go into making 100 worksheets and reference but that seems really messy and labor intensive?

  5. #5
    Registered User
    Join Date
    09-30-2018
    Location
    Australia
    MS-Off Ver
    Excel 2013
    Posts
    9
    Quote Originally Posted by mikerickson View Post
    Rather than looping, you could use code like
    Please Login or Register  to view this content.
    Thanks for the tip mike I really appreciate it. Forgive my lack of knowledge but do you mean for not looping do I keep integer etc at the start of the code etc?

  6. #6
    Registered User
    Join Date
    09-30-2018
    Location
    Australia
    MS-Off Ver
    Excel 2013
    Posts
    9

    Re: Userform Textboxes and Comboboxes to Populate certain cells across 100 columnsx1colata

    Hi Mike

    Again thanks for the tip as I now have data being fed into the cells whereas before I only got errors!.. Unfortunately now the code populates (duplicates) the same data entry into all cells 100 columns, when what I need it to do is feed 1 column at a time. Again thanks but i think im out of my depth completely here..

    This is what I have as start of the code:

    Please Login or Register  to view this content.
    Last edited by Cheeeopers; 10-22-2018 at 05:07 AM.

  7. #7
    Forum Guru Kyle123's Avatar
    Join Date
    03-10-2010
    Location
    Leeds
    MS-Off Ver
    365 Win 11
    Posts
    7,238

    Re: Userform Textboxes and Comboboxes to Populate certain cells across 100 columnsx1colata

    It would be much easier if you post a sample workbook:

    Attach a sample workbook (not a picture or pasted copy). Make sure there is just enough data to demonstrate your need. Include a BEFORE sheet and an AFTER sheet in the workbook if needed to show the process you're trying to complete or automate. Make sure your desired results are shown, mock them up manually if necessary.

    Remember to desensitize the data.

    Click on GO ADVANCED and then scroll down to Manage Attachments to open the upload window.

  8. #8
    Forum Guru Kyle123's Avatar
    Join Date
    03-10-2010
    Location
    Leeds
    MS-Off Ver
    365 Win 11
    Posts
    7,238

    Re: Userform Textboxes and Comboboxes to Populate certain cells across 100 columnsx1colata

    Also, Your post does not comply with Rule 2 of our Forum RULES. Use code tags around code.

    Posting code between [CODE]Please [url=https://www.excelforum.com/login.php]Login or Register [/url] to view this content.[/CODE] tags makes your code much easier to read and copy for testing, it also maintains VBA formatting.

    Click on Edit to open your thread, then highlight your code and click the # icon at the top of your post window. More information about these and other tags can be found here

    (This thread should receive no further responses until this moderation request is fulfilled, as per Forum Rule 6)

  9. #9
    Forum Expert mikerickson's Avatar
    Join Date
    03-30-2007
    Location
    Davis CA
    MS-Off Ver
    Excel 2011
    Posts
    6,229

    Re: Userform Textboxes and Comboboxes to Populate certain cells across 100 columnsx1colata

    Quote Originally Posted by Cheeeopers View Post
    Hi Mike

    Again thanks for the tip as I now have data being fed into the cells whereas before I only got errors!.. Unfortunately now the code populates (duplicates) the same data entry into all cells 100 columns, when what I need it to do is feed 1 column at a time...
    One column at a time?
    That sounds like you want the user to enter values in 27 controls one hundred times?

    I find it easer to just enter into the cells. Plus everyone knows how to fill out a spreadsheet, forcing them thru a userform would just increase training time (and errors)

  10. #10
    Registered User
    Join Date
    09-30-2018
    Location
    Australia
    MS-Off Ver
    Excel 2013
    Posts
    9

    Re: Userform Textboxes and Comboboxes to Populate certain cells across 100 columnsx1colata

    Done, Sorry told you i was a noob.

    Now i know, unlike my vba writing...

    Thanks for the heads up

  11. #11
    Registered User
    Join Date
    09-30-2018
    Location
    Australia
    MS-Off Ver
    Excel 2013
    Posts
    9

    Re: Userform Textboxes and Comboboxes to Populate certain cells across 100 columnsx1colata

    Hi Mike

    Yes I would like the userform to fill in one column at a time in the referenced cells. As the amount of cells required scrolling over is alot im sure a correctly coded vba userform would reduce data input 10 fold.

    So the userform would need to reload and run again (I think using a sequential item number textbox?) up to 100 times but finish after a pre-determined quantity as noted in the attached excel file notes.

    I hope its easily followed??

    Either way (if its achievable or not) i appreciate you looking at it.

    Apologies for the inconvenience if any.
    Attached Files Attached Files

  12. #12
    Valued Forum Contributor dotchiejack's Avatar
    Join Date
    05-21-2015
    Location
    Antwerp,Belgium
    MS-Off Ver
    2016
    Posts
    507

    Re: Userform Textboxes and Comboboxes to Populate certain cells across 100 columnsx1colata

    Now that I see your example and understand what you want, I'll make an example later this afthernoon.
    Click the * Add Reputation below to say thanks.

  13. #13
    Valued Forum Contributor dotchiejack's Avatar
    Join Date
    05-21-2015
    Location
    Antwerp,Belgium
    MS-Off Ver
    2016
    Posts
    507

    Re: Userform Textboxes and Comboboxes to Populate certain cells across 100 columnsx1colata

    See if this is what you are looking for.
    First you have to choose the frame and then the info in the text -and comboboxes will be added to the correct column.
    Also the combined entries from 2 text and or comboboxes are not clear to me.(hope it is ok)
    As you did not give any information with what the comboboxes have to be filled I guested and used numbers except for one there I used Internal & External. (this can be changed very easely)
    If you have questions, just ask
    Hope this helps.
    Attached Files Attached Files

  14. #14
    Registered User
    Join Date
    09-30-2018
    Location
    Australia
    MS-Off Ver
    Excel 2013
    Posts
    9

    Re: Userform Textboxes and Comboboxes to Populate certain cells across 100 columnsx1colata

    Hi Dotchiejack, thank you very much as it worked a treat! albeit on your excel file you sent me

    My next hurdle is assigning the userform to be controlled by a command button on a different worksheet to drive the input of items you so kindly put together for me (as the Frame Input worksheet will be hidden, so no access to the button). Again my skills in coding are very lacking (I am the old dog you cannot teach tricks too...) lol

    I really appreciate everyones help on this - its going to make my job easier

  15. #15
    Valued Forum Contributor dotchiejack's Avatar
    Join Date
    05-21-2015
    Location
    Antwerp,Belgium
    MS-Off Ver
    2016
    Posts
    507

    Re: Userform Textboxes and Comboboxes to Populate certain cells across 100 columnsx1colata

    You can put the button on any page you like, the code will work.
    See the example. All sheets are hidden except the cover page.
    I did not change the code in the userform, I just added a cover sheet.
    Attached Files Attached Files

  16. #16
    Registered User
    Join Date
    09-30-2018
    Location
    Australia
    MS-Off Ver
    Excel 2013
    Posts
    9

    Re: Userform Textboxes and Comboboxes to Populate certain cells across 100 columnsx1colata

    Thanks dotchiejack, appreciate it mate. I found when I copied your userform text/combo-boxes into a userform I already had, it kept the Rowsource input data in my orioginal userform text&combo boxes and applied them to the copied text&combo-boxes (maybe an FYI but you probably already know that one?).

    Anywho I am now trying to intergrate the checkboxes to give a value of yes or no (again per column in a particular cell) and I cant find any examples in the forum or online.. can you help once more? please..

  17. #17
    Valued Forum Contributor dotchiejack's Avatar
    Join Date
    05-21-2015
    Location
    Antwerp,Belgium
    MS-Off Ver
    2016
    Posts
    507

    Re: Userform Textboxes and Comboboxes to Populate certain cells across 100 columnsx1colata

    example.
    Code also under the Add button.
    Please Login or Register  to view this content.
    If checkbox is ticked then the cell will contain yes
    if checkbox is not ticked the cell will contain no
    Change 476 to the correct row number.
    Do the same for the second checkbox.

  18. #18
    Registered User
    Join Date
    09-30-2018
    Location
    Australia
    MS-Off Ver
    Excel 2013
    Posts
    9

    Re: Userform Textboxes and Comboboxes to Populate certain cells across 100 columnsx1colata

    Thanks Dotchiejack, I tried importing the code in but unfortunately it isnt working, am i missing something?

    The extract is the last part of the add button code..

    Please Login or Register  to view this content.

  19. #19
    Valued Forum Contributor dotchiejack's Avatar
    Join Date
    05-21-2015
    Location
    Antwerp,Belgium
    MS-Off Ver
    2016
    Posts
    507

    Re: Userform Textboxes and Comboboxes to Populate certain cells across 100 columnsx1colata

    Code is correct, place is correct.
    Is your checkboxname correct? Chb_01.
    Note: you also use 476 in CB_25, but this has nothing to do with your problem, the checkbox event comes afther CB25 and overwrites the cell.

+ 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. [SOLVED] Populating userform textboxes basis of results from 2 userform comboboxes
    By rlh in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 04-11-2017, 10:26 AM
  2. [SOLVED] Code for all TextBoxes; Comboboxes and CheckBoxes in an UserForm
    By pipoliveira in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 10-06-2016, 05:19 AM
  3. populate textboxes in userform based on cells values
    By Yokosuka in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 09-08-2016, 01:50 PM
  4. userform with 3 comboboxes and textboxes send to sheet
    By cfinch100 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 03-15-2013, 03:15 PM
  5. Excel 2003: Worksheet cells populate textboxes on a userform
    By SHU_STU_0609 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 01-09-2013, 01:24 AM
  6. Data Validation for all TextBoxes and Comboboxes in Userform
    By singhabhijitkumar in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 08-12-2010, 05:48 PM
  7. How to empty all comboboxes and textboxes in a userform
    By LoveCandle in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 05-06-2009, 02:28 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