+ Reply to Thread
Results 1 to 12 of 12

Adding Set of Empty Rows to Bottom of Table with Radio Button Macro

  1. #1
    Registered User
    Join Date
    12-18-2021
    Location
    Indianapolis, IN
    MS-Off Ver
    Home and Student '19
    Posts
    5

    Adding Set of Empty Rows to Bottom of Table with Radio Button Macro

    Hi all,
    I hope this message finds you well. I am somewhat new to excel, so bear with me. I haven't really ventured into VBA and am pretty limited to the recorder at the moment but am learning. I think this is an absolute/relative reference mistake somewhere, but I seem to be stuck on it.

    I would like my button to add a set of rows (four rows per sample) to the bottom of the table, and then numerically add 1 to the sample number (i.e. add Sample 2, 3, 4... for each time the button is clicked). This will be used as a test template creator to be used with varying test samples sizes (sample count). Would appreciate any help or direction or a video that may nudge me in the right direction. The problem I'm having is with the Sample number not counting correctly after Sample 2.

    Sub Macro19()
    '
    ' Macro19 Macro
    '

    '
    Range("B5:U8").Select
    Selection.Copy
    Range("B9").Select
    Selection.Insert Shift:=xlDown
    Range("B9:B12").Select
    Application.CutCopyMode = False
    ActiveCell.FormulaR1C1 = "=R[-4]C+1"
    Range("B9:B12").Select
    Selection.Copy
    Range("M9:M12").Select
    ActiveSheet.Paste
    Range("D5").Select
    End Sub

  2. #2
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,776

    Re: Adding Set of Empty Rows to Bottom of Table with Radio Button Macro

    Please see the yellow banner at the top of the page.


    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.
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


  3. #3
    Forum Contributor GWteB's Avatar
    Join Date
    12-13-2021
    Location
    GMT +1
    MS-Off Ver
    2013
    Posts
    136

    Re: Adding Set of Empty Rows to Bottom of Table with Radio Button Macro

    Hi & welcome to ExcelForum.

    In case your table is called Table1, adding one row to the bottom of your table can be done with this code:
    Please Login or Register  to view this content.
    In case the bottom row contains any formulas, they will be copied downwards to the newly added row.

  4. #4
    Registered User
    Join Date
    12-18-2021
    Location
    Indianapolis, IN
    MS-Off Ver
    Home and Student '19
    Posts
    5

    Re: Adding Set of Empty Rows to Bottom of Table with Radio Button Macro

    Quote Originally Posted by TMS View Post
    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.
    OK I think I have what's needed to demonstrate what I am trying to do. I'd like to be able to click radio button X number of times and have X number of samples (2 rows per Sample) added to the bottom of table, while updating the sample number each time a sample is added to the table. So, I'd like to be able to click radio button in "Forces - 1H" 5 times and have Samples 2,3,4,5,6 added to the table. However, my button adds samples 2,2,2,2,2. I think this should be an easy fix but am newer to excel. Thanks.
    Attached Files Attached Files
    Last edited by StagHunt; 12-19-2021 at 05:15 PM.

  5. #5
    Forum Contributor GWteB's Avatar
    Join Date
    12-13-2021
    Location
    GMT +1
    MS-Off Ver
    2013
    Posts
    136

    Re: Adding Set of Empty Rows to Bottom of Table with Radio Button Macro

    See if this is what you're after:

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

  6. #6
    Forum Contributor GWteB's Avatar
    Join Date
    12-13-2021
    Location
    GMT +1
    MS-Off Ver
    2013
    Posts
    136

    Re: Adding Set of Empty Rows to Bottom of Table with Radio Button Macro

    Sorry, forgot to update the sample numbers:

    Please Login or Register  to view this content.

  7. #7
    Registered User
    Join Date
    12-18-2021
    Location
    Indianapolis, IN
    MS-Off Ver
    Home and Student '19
    Posts
    5

    Re: Adding Set of Empty Rows to Bottom of Table with Radio Button Macro

    Thanks, this appears to work.

  8. #8
    Registered User
    Join Date
    12-18-2021
    Location
    Indianapolis, IN
    MS-Off Ver
    Home and Student '19
    Posts
    5

    Re: Adding Set of Empty Rows to Bottom of Table with Radio Button Macro

    Quote Originally Posted by GWteB View Post
    Sorry, forgot to update the sample numbers:

    Please Login or Register  to view this content.
    Thanks, this appears to work.

  9. #9
    Forum Contributor GWteB's Avatar
    Join Date
    12-13-2021
    Location
    GMT +1
    MS-Off Ver
    2013
    Posts
    136

    Re: Adding Set of Empty Rows to Bottom of Table with Radio Button Macro

    You are welcome and thanks for letting me know.

  10. #10
    Registered User
    Join Date
    12-18-2021
    Location
    Indianapolis, IN
    MS-Off Ver
    Home and Student '19
    Posts
    5

    Re: Adding Set of Empty Rows to Bottom of Table with Radio Button Macro

    I'm interested in learning more about this code. Say I wanted to Add 4 or 5 or n # of rows per sample instead of 2 as in my example, which part of the code should I be focusing on? or is it not as easy as that? being new to excel, the code seems quite obtuse. I believe I am hung up on the Sample # counter, as I can get everything else to copy using recorder but Sample # does not update. example #2 attached.
    Attached Files Attached Files
    Last edited by StagHunt; 12-20-2021 at 06:53 PM.

  11. #11
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,776

    Re: Adding Set of Empty Rows to Bottom of Table with Radio Button Macro

    I would guess that, wherever you see a 2, you change that to 4, or 5, or n. So, Offset(-2) and Resize(2, 9).

  12. #12
    Forum Contributor GWteB's Avatar
    Join Date
    12-13-2021
    Location
    GMT +1
    MS-Off Ver
    2013
    Posts
    136

    Re: Adding Set of Empty Rows to Bottom of Table with Radio Button Macro

    Due to your additional request, I have changed the approach.
    The supplied code assumes that the two tables on the same worksheet have an equal number of rows.
    Furthermore, every first column of every table consists of merged cells as in your original case.
    Finally, in cell V3 there's a value that indicates the number of desired duplicates.
    The code can then be used regardless of the number of rows per Sample.
    Please Login or Register  to view this content.
    Attached Files Attached Files

+ 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] Power Query - add empty rows & rows of text below bottom of group
    By josephteh in forum Excel General
    Replies: 1
    Last Post: 11-16-2020, 02:59 PM
  2. [SOLVED] ensure user selects radio button before adding information
    By JamesT1 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-27-2014, 10:00 AM
  3. [SOLVED] Always keep an empty row at the bottom of a table
    By Habanero Time in forum Excel General
    Replies: 3
    Last Post: 01-21-2014, 05:40 PM
  4. Macro command button to hide empty rows
    By djauncey in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 08-31-2012, 10:42 AM
  5. Macro Button to delete all rows that are empty
    By timmyjc18 in forum Excel General
    Replies: 3
    Last Post: 06-22-2012, 09:38 PM
  6. Adding values to a Radio Button?
    By CreamSoda in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 05-20-2011, 06:21 PM
  7. URGENT!! Use macro button to hide empty columns and rows...HELP!!!!
    By Hawk in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 07-08-2005, 06:05 PM

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