+ Reply to Thread
Results 1 to 2 of 2

Copy and Insert Macro

  1. #1
    Registered User
    Join Date
    01-29-2013
    Location
    United States
    MS-Off Ver
    Excel 2010
    Posts
    1

    Copy and Insert Macro

    I have the below code connected to a button intended to copy a sample row and add 10 more to the bottom of my data set.
    It's driving my crazy that I can't get it to work!
    Any help would be greatly appreciated. Happy to answer any questions


    Sub AddRows()
    Application.ScreenUpdating = False
    Application.DisplayAlerts = False
    ActiveSheet.Unprotect ("password")

    Sheets("Data").Select
    On Error Resume Next
    If Sheets("Data").AutoFilterOn = True Then ActiveSheet.ShowAllData

    lastrow = Cells.Find("*", SearchOrder:=xlByRows, SearchDirection:=xlPrevious).Row

    Application.CutCopyMode = False
    Rows("3:3").EntireRow.Copy
    Rows(lastrow + 1 & ":" & lastrow + 10).Insert Shift:=xlDown
    Application.CutCopyMode = False
    Rows(lastrow + 1 & ":" & lastrow + 10).EntireRow.Hidden = False


    ActiveSheet.Protect ("password"), DrawingObjects:=True, Contents:=True, Scenarios:=True _
    , AllowFormattingCells:=True, AllowFormattingColumns:=True, _
    AllowFormattingRows:=True, AllowFiltering:=True

    End Sub

  2. #2
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 insider Version 2504 Win 11
    Posts
    24,706

    Re: Copy and Insert Macro

    Your code is copying row three and pasting into the ten rows below the last row. If this is not what you are looking to do, please be more specific in your explanation.

    Why do you need the line of code to unhide the 10 rows?
    Alan עַם יִשְׂרָאֵל חַי


    Change an Ugly Report with Power Query
    Database Normalization
    Complete Guide to Power Query
    Man's Mind Stretched to New Dimensions Never Returns to Its Original Form

+ 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] Macro to copy row, insert below, invert amt, and insert blank row between each new tx
    By raquel1227 in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 03-07-2013, 12:56 PM
  2. Macro: Copy Row and Insert it ; Insert Odd Year
    By buto87 in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 04-25-2012, 08:55 AM
  3. Macro to copy and insert
    By morayman in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 11-10-2011, 09:43 AM
  4. Macro to insert copy and insert formulas only to next blank row
    By bob in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 06-30-2006, 07:10 AM
  5. copy insert macro
    By snax500 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 01-14-2005, 06:06 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