+ Reply to Thread
Results 1 to 4 of 4

Macro: Need help modifying macro, pasting over a row of data

Hybrid View

  1. #1
    Registered User
    Join Date
    07-10-2013
    Location
    USA
    MS-Off Ver
    Excel 2010
    Posts
    86

    Macro: Need help modifying macro, pasting over a row of data

    Need some help with my macro (see below).
    I have two sheets 1) ap modified 2) gl download

    it's merging the two sheets together. however, it's pasting over the last row of data.
    For example, gl download has data from row 4 to row 100
    The Macro is pasting data from ap modified starting in row 100 of gl download instead of row 101.

    how can i correct this? thanks!



    Sub C_Merge()
    Dim w1 As Worksheet, w2 As Worksheet
    Set w1 = Sheets("ap modified")
    Set w2 = Sheets("gl download")
    Dim lr1 As Long, lr2 As Long
    lr1 = w1.Range("A" & Rows.Count).End(xlUp).Row
    lr2 = w2.Range("A" & Rows.Count).End(xlUp).Row

    Application.ScreenUpdating = False
    w1.Range("A4:U" & lr1).Copy w2.Range("A" & lr2)
    Application.CutCopyMode = False
    Application.ScreenUpdating = True
    MsgBox "Task Completed!"
    End Sub

  2. #2
    Forum Expert
    Join Date
    01-23-2013
    Location
    USA
    MS-Off Ver
    Microsoft 365 aka Office 365
    Posts
    3,863

    Re: Macro: Need help modifying macro, pasting over a row of data

    Hi,

    Try:
    w1.Range("A4:U" & lr1).Copy w2.Range("A" & lr2 + 1)
    In the future please add CODE TAGS. See the forum rules for instructions.

    Lewis

  3. #3
    Forum Expert
    Join Date
    08-12-2012
    Location
    Sydney, Australia
    MS-Off Ver
    Excel 2010
    Posts
    5,636

    Re: Macro: Need help modifying macro, pasting over a row of data

    firstly
    forum rule 3
    please use [code] tags to wrap your coding
    http://www.excelforum.com/forum-rules/642590-forum-rules.html

    add a +1
    w1.Range("A4:U" & lr1).Copy w2.Range("A" & lr2 + 1)
    Last edited by humdingaling; 08-11-2014 at 09:08 PM.
    If you are satisfied with the solution(s) provided, please mark your thread as Solved.
    Select Thread Tools-> Mark thread as Solved. To undo, select Thread Tools-> Mark thread as Unsolved.

  4. #4
    Registered User
    Join Date
    07-10-2013
    Location
    USA
    MS-Off Ver
    Excel 2010
    Posts
    86

    Re: Macro: Need help modifying macro, pasting over a row of data

    it worked! thanks guys. i'll abide by the rules next time, thanks for letting me know.

+ 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 for Selecting and Modifying Special data in Graph
    By Haidar123 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 04-03-2014, 03:09 PM
  2. Modifying a macro to only clear a cell if it contains data and not a formula
    By ianpwilliams in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 05-16-2013, 01:09 PM
  3. Modifying sort data macro
    By rhudgins in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 07-07-2010, 05:43 PM
  4. Modifying VBA to create new macro for recording data
    By sighlent1 in forum Excel General
    Replies: 2
    Last Post: 12-30-2009, 08:26 PM
  5. Modifying data before pasting
    By xyz123 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 11-06-2008, 07:24 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