+ Reply to Thread
Results 1 to 17 of 17

How to populate multiple cells from multiple checkboxes from a VBA Form in Excel

  1. #1
    Registered User
    Join Date
    03-09-2021
    Location
    London
    MS-Off Ver
    Version 2102
    Posts
    9

    How to populate multiple cells from multiple checkboxes from a VBA Form in Excel

    Hi ,

    I have created an excel workbook where with the help of the form you can easily create a fabrication quote.

    I have a pre styled section on the worksheet which at the end will be printed on an A4 sheet together with the quotes to what I need some help

    on the form I have 10 items which can be added to the quote by checking the checkbox.. this then will show it price on the form and allow to chose the quantity.. this is all done but I am having difficulties to move the checked items to the worksheet.

    My allocated space would be from line 31 to 63 using every second line

    I would like to move the information from the form to the sheet in a way that if I uncheck one of the previously checked items to remove it from the sheet as well fore more it will move the following checked items on line up so I am not leaving gaps

    Do I have to write the code on the checkbox or should generate a module instead?

    If you have any idea please let me know.

  2. #2
    Forum Expert torachan's Avatar
    Join Date
    12-27-2012
    Location
    market harborough, england
    MS-Off Ver
    Excel 2010
    Posts
    4,304

    Re: How to populate multiple cells from multiple checkboxes from a VBA Form in Excel

    A lot easier for us to work with your actual workbook - see big yellow banner at head of page - remember to de-sensitise any data.
    Seems a simple request on the face of it - I will lookout for your further posting.
    torachan.
    Welcome to the forum

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

  3. #3
    Registered User
    Join Date
    03-09-2021
    Location
    London
    MS-Off Ver
    Version 2102
    Posts
    9

    Re: How to populate multiple cells from multiple checkboxes from a VBA Form in Excel

    Please find attached the workbook and screenshots of what I would like to achieve on that particular selection
    Attached Images Attached Images
    Attached Files Attached Files

  4. #4
    Forum Expert torachan's Avatar
    Join Date
    12-27-2012
    Location
    market harborough, england
    MS-Off Ver
    Excel 2010
    Posts
    4,304

    Re: How to populate multiple cells from multiple checkboxes from a VBA Form in Excel

    seperate module - loop through the check boxes - put the true checkbox values directly into sheet in sequence - ignore false checkboxes in the loop.
    note; in present checkbox code you read from sheet1 and then unnecessarily pass the value back to sheet1.
    the actual print area also need setting in pdf at the moment it only defines the save area.
    if stuck shout again.
    torachan.

  5. #5
    Registered User
    Join Date
    03-09-2021
    Location
    London
    MS-Off Ver
    Version 2102
    Posts
    9

    Re: How to populate multiple cells from multiple checkboxes from a VBA Form in Excel

    Yes.. i was sending back the data to sheet1 then reading that data from sheet2, this is because I had some conflict issues of the data sent to the sheet messing up the cells currency format..

    Now I am not 100% sure how can I formulate a loop statement that can handle all checkboxes and data to be read from sheet1.. I need a starting point.

    Should the codding be behing each checkbox or I should have a module created then refer to it from each checkbox.. sorry I am beginner in this

  6. #6
    Forum Expert torachan's Avatar
    Join Date
    12-27-2012
    Location
    market harborough, england
    MS-Off Ver
    Excel 2010
    Posts
    4,304

    Re: How to populate multiple cells from multiple checkboxes from a VBA Form in Excel

    Attached much modified code.
    To aid the compressing of code there is a dummy hidden textbox (QB16) - it enables a continuos loop to be used.
    QB16 is visible in the form development window and is hidden at runtime.
    Also iterated out 3 or 4 lines on the 'Fabrication' button just to enable moving between forms.
    Happy to answer any questions although I think the flow/code is fairly straightforward.
    I have put the sheet loading loop in the 'Save pdf' key immediately before the save routine.
    torachan.
    Attached Files Attached Files

  7. #7
    Registered User
    Join Date
    03-09-2021
    Location
    London
    MS-Off Ver
    Version 2102
    Posts
    9

    Re: How to populate multiple cells from multiple checkboxes from a VBA Form in Excel

    Yes, This looks exactly what I was looking for, I just need to be able to transform the prices back to currency so The sheet formula can sum them up. Thank you for your help, I will put the code in my final application to see if is all ok and will get back if other question rises regarding this.
    I would love to understand more about the controls ( is this regarding the selection of quantity and x for the number of checkboxes? .. also you set up z as a long variable but where have you used it and for what? ** thank you for explaining )

  8. #8
    Forum Expert torachan's Avatar
    Join Date
    12-27-2012
    Location
    market harborough, england
    MS-Off Ver
    Excel 2010
    Posts
    4,304

    Re: How to populate multiple cells from multiple checkboxes from a VBA Form in Excel

    Ignore the 'z' Dim declaration (you can delete it) left over from initial attempt at sequencing code.
    Fortuneatly you had refrained from giving your CheckBoxes/ComboBoxes/TextBoxes fancy individual names.
    Each group having the same numerical suffix, this made looping through easy rather than dealing with 17 sets of data transfer.
    Normally I do not bother to change the default control name (e.g. TextBox1) just make a written list whilst developing (annotate relevant controls, if your memory is has bad as mine).

  9. #9
    Registered User
    Join Date
    03-09-2021
    Location
    London
    MS-Off Ver
    Version 2102
    Posts
    9

    Re: How to populate multiple cells from multiple checkboxes from a VBA Form in Excel

    I have done the changes and all works fine except for one thing.. I cant sum up the populated cells with the prices. It gives me a green triangle in the cells saying it is a text format so I was trying to transform the cells from VBA with

    Sheet2.Range("J31:J63").Style= "Currency"
    ' also tryed with .Numberformat

    or

    Sheet2.Range("J31:J63").Value= Format(Sheet2.Range("J31:J63").Value, "£#,##0.00")

    I have no luck.. it shows me in currency but at the bottom of the page where should be the total, I left the code =Sum(J31:J63) which won't add them up.


    Is there any solution to this?

  10. #10
    Forum Expert torachan's Avatar
    Join Date
    12-27-2012
    Location
    market harborough, england
    MS-Off Ver
    Excel 2010
    Posts
    4,304

    Re: How to populate multiple cells from multiple checkboxes from a VBA Form in Excel

    post your workbook so that we are looking at the same hymn sheet.

  11. #11
    Registered User
    Join Date
    03-09-2021
    Location
    London
    MS-Off Ver
    Version 2102
    Posts
    9

    Re: How to populate multiple cells from multiple checkboxes from a VBA Form in Excel

    I have attached the document with a screenshot of the result..
    Attached Images Attached Images
    Attached Files Attached Files

  12. #12
    Forum Expert torachan's Avatar
    Join Date
    12-27-2012
    Location
    market harborough, england
    MS-Off Ver
    Excel 2010
    Posts
    4,304

    Re: How to populate multiple cells from multiple checkboxes from a VBA Form in Excel

    You appear to have removed the summation code ?????
    There should be no on sheet formula - this was done in the code as was the formatting.
    Remove formula from sheet and paste back the code below.

    Please Login or Register  to view this content.

  13. #13
    Registered User
    Join Date
    03-09-2021
    Location
    London
    MS-Off Ver
    Version 2102
    Posts
    9

    Re: How to populate multiple cells from multiple checkboxes from a VBA Form in Excel

    This works in the test document but as I changed into my original workbook it has a glitch that doesnt add up the 2 results but writes them next to each other in the cell.

    i tried to change the the way that the first value appears on sheet by sending its value to another sheet and copy it to the final sheet from there.
    Do you have an idea why is this happening? please see image attached
    Attached Images Attached Images

  14. #14
    Forum Expert torachan's Avatar
    Join Date
    12-27-2012
    Location
    market harborough, england
    MS-Off Ver
    Excel 2010
    Posts
    4,304

    Re: How to populate multiple cells from multiple checkboxes from a VBA Form in Excel

    without the actual workbook it would be guesswork - desenstise data and upload the workbook should then be easy to fix.

  15. #15
    Registered User
    Join Date
    03-09-2021
    Location
    London
    MS-Off Ver
    Version 2102
    Posts
    9

    Re: How to populate multiple cells from multiple checkboxes from a VBA Form in Excel

    I Have attached the simplified workbook..

    ' I had overwritten the X in the corner of the windows so no-one else from the company can enter to the coding part.. therefore the only way i am able to go to developer mode is opening an empty excel file and entering developement mode then opening this workbook and stopping it from development mode



    So my problem here is between the customised which now works fine and the stocked prices where the overall prices are added next to each other...

    ** another question I have is that.. is there a way to return from the fabrication page with the back button to the initial page...?
    Attached Files Attached Files

  16. #16
    Forum Expert torachan's Avatar
    Join Date
    12-27-2012
    Location
    market harborough, england
    MS-Off Ver
    Excel 2010
    Posts
    4,304

    Re: How to populate multiple cells from multiple checkboxes from a VBA Form in Excel

    Paste the code below over existing final print.
    Cell addition appeared to concatenate so I have attributed the values to variables for the addition.

    If you want to break into your program there is no need to open another empty workbook
    Hold down 'Ctrl' and press 'Pause/Break' this usually takes you straight to the code editor.


    Please Login or Register  to view this content.
    Please Login or Register  to view this content.

  17. #17
    Registered User
    Join Date
    03-09-2021
    Location
    London
    MS-Off Ver
    Version 2102
    Posts
    9

    Re: How to populate multiple cells from multiple checkboxes from a VBA Form in Excel

    I will try this.. also thank you for the shortcut..

    for the back button as both.. customised uses the same fabrication sheet as the stocked stones.. so if i would go through the customised section to fabrication and press back.. this code will end up taking me back to the stocked stones

+ 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] Select multiple Checkboxes in user form
    By kramvreg in forum Excel Programming / VBA / Macros
    Replies: 17
    Last Post: 04-23-2020, 02:41 PM
  2. Multiple checkboxes to populate single cell
    By Watchdawg in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 12-13-2019, 12:50 PM
  3. [SOLVED] Linking multiple checkboxes within one cell to multiple cells
    By Dena in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 09-13-2017, 02:07 PM
  4. [SOLVED] Userform to populate active cell using checkboxes - multiple responses applicable
    By Jonsocks in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 06-13-2017, 08:30 PM
  5. [SOLVED] How to mimic ctrl-select using multiple checkboxes on a form
    By vbapadawan in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 07-07-2015, 02:53 AM
  6. How to create an order form with drop down lists that populate multiple cells
    By d_washington in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 09-17-2012, 10:23 AM
  7. [SOLVED] Macro to collect data from Excel Form and populate multiple tabs
    By kande in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 03-26-2012, 11:15 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