+ Reply to Thread
Results 1 to 5 of 5

Copy and paste set of rows repeatedly at click of button

Hybrid View

  1. #1
    Registered User
    Join Date
    05-07-2013
    Location
    Sydney
    MS-Off Ver
    Excel 2010
    Posts
    6

    Copy and paste set of rows repeatedly at click of button

    Hi,

    I am very new to VBA so bear with me! I have done quite a bit of research into this to no avail (I have no macros I can show). Using Excel 2010, I am trying to write VBA code to insert a set of 24 rows above a separator bar in an Excel sheet (to be treated as a form), and copy and paste a range at the click of a button (by the user) underneath the last range in the form.

    The idea is to provide the user a button they can click if they want to insert an additional "table" for them to complete underneath the existing ones.

    The reason I need a macro for this is because the sheet will be protected.
    The reason for the separator bar (always to be on the bottom) is for formal/professional appearances.

    Attached is a workbook with current and desired situations.

    Cheers for your help!
    Attached Files Attached Files

  2. #2
    Forum Expert NeedForExcel's Avatar
    Join Date
    03-16-2013
    Location
    Pune, India
    MS-Off Ver
    Excel 2016:2019, MS 365
    Posts
    3,879

    Re: Copy and paste set of rows repeatedly at click of button

    Please see the file attached!!

    Please revert if this was not what you were looking for!!

    But you will have to Protect/Unprotect sheet for which I can write you a line of code..

    Thank You,

    Deep
    Attached Files Attached Files
    Cheers!
    Deep Dave

  3. #3
    Forum Expert NeedForExcel's Avatar
    Join Date
    03-16-2013
    Location
    Pune, India
    MS-Off Ver
    Excel 2016:2019, MS 365
    Posts
    3,879

    Re: Copy and paste set of rows repeatedly at click of button

    Just change the code to this -


    Sub FillForm()
    
        Dim LR As Integer
        
        Sheets("Current").Unprotect Password:=""
        
        LR = Sheets("Current").Cells(Rows.Count, 2).End(xlUp).Row + 3
        
        Range("B" & LR - 25 & ":" & "H" & LR).Copy
        
        Cells(LR + 1, 2).Select
        
        ActiveCell.PasteSpecial
        
        ActiveCell.Select
        
        Application.CutCopyMode = False
        
        ActiveSheet.Protect Password:="", DrawingObjects:=False, Contents:=True, Scenarios:= _
                False
    
    End Sub
    Wherever Password:="" is mentioned, you can put your desired Password between "".

    Thank You,

    Deep

  4. #4
    Registered User
    Join Date
    05-07-2013
    Location
    Sydney
    MS-Off Ver
    Excel 2010
    Posts
    6

    Re: Copy and paste set of rows repeatedly at click of button

    Hi Deep,

    This is brilliant! Seems to work perfectly.

    Thanks so much for your help! Very quick too!

    RN

  5. #5
    Forum Expert NeedForExcel's Avatar
    Join Date
    03-16-2013
    Location
    Pune, India
    MS-Off Ver
    Excel 2016:2019, MS 365
    Posts
    3,879

    Re: Copy and paste set of rows repeatedly at click of button

    Glad it helped!!

    Cheers!!

    Deep

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Tags for this Thread

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