VBA only copy data from one sheet that isn't already on another sheet

mik1996

New Member
Joined
Mar 15, 2023
Messages
23
Office Version
  1. 365
  2. 2021
  3. 2019
Platform
  1. Windows
Morning,



I currently have vba to copy a report from one sheet (Rufus Unal) to another (UTM Unal Cash Report), rather than copying the whole report I would ideally like it to only copy data from the Rufus Unal Sheet that isn’t already on the other sheet as currently it just copies all the data. Column A has unique references in both sheets which is what the criteria would be whether to copy the data or not, also instead of pasting data into row 10 is it possible for it to be pasted underneath the last line of data. Please see current coding below:

VBA Code:
Sub RunUac()

Dim LR1 As Long
Dim LR2 As Long
Dim LR3 As Long
Dim LR4 As Long
Dim wb1 As Workbook
Dim wb2 As Workbook
Set wb1 = ThisWorkbook
Dim cell As Range

Application.ScreenUpdating = False

Worksheets("Rufus Unal").Visible = True


Workbooks.Open "K:\Finance\Unallocated Cash\Reconciliations\Templates/Rufus_Unal.xlsx", ReadOnly:=True


Workbooks("Rufus_Unal.xlsx").Activate

Sheets("UCRR001x").Activate

LR1 = Cells(Rows.Count, "a").End(xlUp).Row

Range("A2:O" & LR1).Copy

    wb1.Activate
    Sheets("Rufus Unal").Select
    Range("A11").PasteSpecial Paste:=xlPasteValues
    Application.CutCopyMode = False
        
   
Workbooks("Rufus_Unal.xlsx").Activate

ActiveWorkbook.Close SaveChanges:=False

Sheets("GL").Select
    Range("Sheet16[[#Headers],[Accnt.]]").Select
    Selection.ListObject.QueryTable.Refresh BackgroundQuery:=False
    
Sheets("Rufus Unal").Select
    LR1 = Cells(Rows.Count, "b").End(xlUp).Row

Range("A11:A" & LR1).Copy
    Sheets("UTM Unal Cash Report").Select
    Range("A10").PasteSpecial Paste:=xlPasteValues
    Application.CutCopyMode = False

Sheets("Rufus Unal").Select
Range("I11:I" & LR1).Copy
    Sheets("UTM Unal Cash Report").Select
    Range("B10").PasteSpecial Paste:=xlPasteValues
    Application.CutCopyMode = False
    
Sheets("Rufus Unal").Select
Range("D11:D" & LR1).Copy
    Sheets("UTM Unal Cash Report").Select
    Range("C10").PasteSpecial Paste:=xlPasteValues
    Application.CutCopyMode = False

Sheets("Rufus Unal").Select
Range("B11:B" & LR1).Copy
    Sheets("UTM Unal Cash Report").Select
    Range("D10").PasteSpecial Paste:=xlPasteValues
    Application.CutCopyMode = False

Sheets("Rufus Unal").Select
Range("C11:C" & LR1).Copy
    Sheets("UTM Unal Cash Report").Select
    Range("E10").PasteSpecial Paste:=xlPasteValues
    Application.CutCopyMode = False
    

Sheets("Sign Off Form").Select
     Range("C31").Value = Application.UserName
     Application.ScreenUpdating = True

End Sub

Any help would be very much appreciated



Thank you
 

Excel Facts

Wildcard in VLOOKUP
Use =VLOOKUP("Apple*" to find apple, Apple, or applesauce

Forum statistics

Threads
1,224,812
Messages
6,181,084
Members
453,021
Latest member
Justyna P

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top