+ Reply to Thread
Results 1 to 10 of 10

Add row/rows to Table based on Userform Checkboxes

  1. #1
    Registered User
    Join Date
    09-11-2015
    Location
    California, usa
    MS-Off Ver
    2010
    Posts
    44

    Add row/rows to Table based on Userform Checkboxes

    Hello all,

    I am attempting to add row/rows to a table based userform checkbox. The following code properly adds the rows and data when check box is true, however, stills adds a row even though the checkbox is false. The data is not added when check box is false.
    I am new to working with tables and would appreciate any insight of how to correct and/or better approach adding rows to table based on checkboxes on a userform.

    Please Login or Register  to view this content.

  2. #2
    Forum Expert gmr4evr1's Avatar
    Join Date
    11-24-2014
    Location
    Texas
    MS-Off Ver
    Office 2010 and 2007
    Posts
    3,448

    Re: Add row/rows to Table based on Userform Checkboxes

    I may be wrong, but, In your If statements, there is no Else to tell excel what to do if the value is not true (False).
    1N73LL1G3NC3 15 7H3 4B1L17Y 70 4D4P7 70 CH4NG3 - 573PH3N H4WK1NG
    You don't have to add Rep if I have helped you out (but it would be nice), but please mark the thread as SOLVED if your issue is resolved.

    Tom

  3. #3
    Registered User
    Join Date
    09-11-2015
    Location
    California, usa
    MS-Off Ver
    2010
    Posts
    44

    Re: Add row/rows to Table based on Userform Checkboxes

    Thank you gmr4evr1 for the reply. Very much appreciated.
    I have tried to add a false argument line to the code previously, however, a row is still added to the table for the specific check box. I have 34 check boxes in the userform and it will add 34 rows to the table and the check boxes which are false will be blank rows. I could easily remove the blank rows with code at the end, however, I would prefer to learn the proper code to not add the row as well as text data if check box is unchecked and false. Any further suggestions and help would be greatly appreciated!

    Please Login or Register  to view this content.

  4. #4
    Forum Expert gmr4evr1's Avatar
    Join Date
    11-24-2014
    Location
    Texas
    MS-Off Ver
    Office 2010 and 2007
    Posts
    3,448

    Re: Add row/rows to Table based on Userform Checkboxes

    Redled89,
    Sorry about that, I looked into it further and realized that adding the false argument wouldn't matter, I just couldn't get back here to let you know.
    Is it possible for you to attach a sample workbook with some of the checkboxes and the code for them?

  5. #5
    Registered User
    Join Date
    09-11-2015
    Location
    California, usa
    MS-Off Ver
    2010
    Posts
    44

    Re: Add row/rows to Table based on Userform Checkboxes

    Gmr4evr1 please see attached sample workbook as requested. I appreciate your time to review and offer possible solution.
    Attached Files Attached Files

  6. #6
    Forum Expert gmr4evr1's Avatar
    Join Date
    11-24-2014
    Location
    Texas
    MS-Off Ver
    Office 2010 and 2007
    Posts
    3,448

    Re: Add row/rows to Table based on Userform Checkboxes

    Redled89,
    I have figured out why it's doing it, haven't quite worked out how to resolve it yet. The lines
    Please Login or Register  to view this content.
    are telling excel to place the value 3 and the lb3 caption 3 rows below the last row which is the reason for the double blank rows. There needs to be a spot in the code where it says IF Cb1 and CB2 are false then skip just one row so the + 3 has to be + 1. Else, run the original code.

  7. #7
    Registered User
    Join Date
    09-11-2015
    Location
    California, usa
    MS-Off Ver
    2010
    Posts
    44

    Re: Add row/rows to Table based on Userform Checkboxes

    Ok thanks again Gmr4evr1. I will play with it some more. Appreciate your time to review.

  8. #8
    Forum Expert gmr4evr1's Avatar
    Join Date
    11-24-2014
    Location
    Texas
    MS-Off Ver
    Office 2010 and 2007
    Posts
    3,448

    Re: Add row/rows to Table based on Userform Checkboxes

    Well, I haven't gotten any further with this. I am starting to think you might have to go with a Select Case statement. Unfortunately, I'm not familiar enough with it to help. I believe that Select Case is kind of like an If/Then statement, but you can have several cases defined and once 1 is found to be true, excel will not look at the others.
    I will keep trying when I can to get it to work without using Select Case when time permits.

    *Until then, Hopefully there is someone else on here that can help with this. *

  9. #9
    Registered User
    Join Date
    09-11-2015
    Location
    California, usa
    MS-Off Ver
    2010
    Posts
    44

    Re: Add row/rows to Table based on Userform Checkboxes

    Thanks for your efforts gmr4evr1! I have a work around code but I have found work arounds can create other challenges.

  10. #10
    Forum Expert gmr4evr1's Avatar
    Join Date
    11-24-2014
    Location
    Texas
    MS-Off Ver
    Office 2010 and 2007
    Posts
    3,448

    Re: Add row/rows to Table based on Userform Checkboxes

    Ohhh yes they can!!

+ 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. VBA Userform to select checkboxes and extract data based on their filter
    By sdhutty in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 11-25-2016, 09:03 AM
  2. [SOLVED] Toggle between userform checkboxes for multiple pairs of checkboxes
    By L plates in forum Excel Programming / VBA / Macros
    Replies: 12
    Last Post: 04-25-2016, 06:31 AM
  3. Change Option Buttons Based on Checkboxes in Userform
    By SoothSailor in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 10-22-2014, 03:12 PM
  4. Print Sheets based on checkboxes in UserForm, Checkboxes also control another macro
    By krackaberr in forum Excel Programming / VBA / Macros
    Replies: 34
    Last Post: 03-05-2013, 11:12 AM
  5. VBA: Userform Checkboxes T/F based on ws Cell values
    By iDealEyes in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 01-29-2013, 08:48 PM
  6. Linking Userform Checkboxes to single rows on a sheet
    By rawcode in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 01-09-2013, 11:10 AM
  7. [SOLVED] Delete values based on deselected checkboxes in userform
    By Tino XXL in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 02-08-2012, 09:32 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