+ Reply to Thread
Results 1 to 3 of 3

Macro for copying rows in sheet1 to end of existing rows in sheet2 based on criteria

Hybrid View

  1. #1
    Registered User
    Join Date
    04-20-2015
    Location
    Norway
    MS-Off Ver
    360
    Posts
    24

    Re: Macro for copying rows in sheet1 to end of existing rows in sheet2 based on criteria

    Thank you, mehmetcik! This works very well

    I changed a few things to get it like I wanted it.
    Sub Merge_Data()
    
    Dim MySheetName As String
        MySheetName = "Merged Data"
        Sheets("Compustat").Copy After:=Sheets("Compustat")
        ActiveSheet.Name = MySheetName
            
        LR1 = Sheets("Compustat").Cells(Rows.Count, 1).End(xlUp).Row
        LR2 = Sheets("CRSP").Cells(Rows.Count, 1).End(xlUp).Row
        LC = Sheets("CRSP").Cells(1, Columns.Count).End(xlToLeft).Column + 8
    
            Sheets("Merged Data").Range("A1:BJ" & 62).Value = Sheets("Compustat").Range("A1:BJ" & 62).Value
            Temp = "BL1:" & Cells(LR2, 63 + LC).Address
            Sheets("Merged Data").Range(Temp).FormulaR1C1 = _
                    "=OFFSET(CRSP!R1C[-63],MATCH(RC1,CRSP!R1C1:R10000C1,0)-1,0)"
    
            Sheets("Merged Data").Range(Temp).Value = Sheets("Merged Data").Range(Temp).Value
    
            Worksheets("Merged Data").Cells(1, 63).Value2 = "CRSP Matches"
    
    End Sub
    Thanks again, this is very helpful!
    Last edited by Karl Gustaf Karsten; 10-22-2015 at 10:09 AM.

+ 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. automatically copying rows to an existing spreadsheet based on criteria
    By Jocatlett in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 01-30-2013, 07:21 PM
  2. Replies: 2
    Last Post: 10-16-2012, 11:34 AM
  3. [SOLVED] macro to copy the formulas in Sheet2 to as many rows as rows available in Sheet1
    By flakedew in forum Excel Programming / VBA / Macros
    Replies: 12
    Last Post: 06-21-2012, 04:52 AM
  4. Replies: 3
    Last Post: 06-06-2012, 05:36 AM
  5. [SOLVED] Copying Data from Sheet1 to sheet2 based on criteria for copy
    By pprane in forum Excel General
    Replies: 1
    Last Post: 04-22-2012, 02:32 AM
  6. Copying Data from Sheet1 to sheet2 based on criteria for copy
    By pprane in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 04-22-2012, 02:07 AM
  7. Help! Hiding rows in sheet2 based on values in sheet1
    By Oti in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 08-23-2011, 12:47 PM
  8. Macro to copy values from Sheet1 to Sheet3, based on criteria in Sheet2
    By John74 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 11-13-2010, 04:55 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