I am new to coding and trying to write a code to append one file to the other. o

Benny1145

New Member
Joined
May 29, 2022
Messages
3
So I have two sheets. sheet2 and sheet 1. On sheet 1, I first of all delete duplicates, then I perform a vlookup (on sheet1) to see if any of the records on sheet1 are not on the main sheet. Records on sheet 1 not found on sheet 2 are then appended to sheet2. i want this to be on the row after the end of the last row on sheet2. I am having issues with the appending. please forgive my coding. i hope to get better. i keep getting the error below. Below is my macro
Sub Macro8()
'
' Macro8 Macro
'

Sheets("sheet2").Select

Columns("C:C").Select
Sheets("sheet2").Select
Columns("C:C").Select
Selection.Insert Shift:=xlToRight, CopyOrigin:=xlFormatFromLeftOrAbove

Sheets("sheet1").Select
'
Rows("1:1").Select
Selection.Delete Shift:=xlUp
Cells.Select
ActiveSheet.Range("$A$1:$G$48").RemoveDuplicates Columns:=2, Header:=xlYes
Range("A1").Select
'
'

'
Columns("C:C").Select
Selection.Insert Shift:=xlToRight, CopyOrigin:=xlFormatFromLeftOrAbove
Range("C2").Select
ActiveCell.Formula2R1C1 = "=if"
Range("C2").Select
ActiveCell.FormulaR1C1 = _
"=IFERROR(VLOOKUP(RC[-1],'sheet2'!C[-1],1,FALSE),""Not Found"")"
Range("C2").Select
Selection.AutoFill Destination:=Range("C2:C10")
Range("C2:C10").Select
Cells.Select
Selection.AutoFilter

'

'
Columns("C:C").Select
Selection.Copy
Columns("C:C").Select
ActiveSheet.Range("$A$1:$L$48").AutoFilter Field:=3, Criteria1:="Not Found"


Cells.Select
Selection.Copy

Sheets("sheet2").Select



Range("A2").Select
Selection.End(xlDown).Select
Range("B1").Select
Selection.End(xlDown).Select
'Range("A10").Select
Range("B" & Rows.Count).End(xlUp).Offset(1).Select

ActiveSheet.Paste
Range("G12").Select
Sheets("Sheet1").Select
Range("H63").Select

Sheets("sheet2").Select
Columns("C:C").Select
Selection.Delete Shift:=xlToLeft
End Sub
1653862670956.png
1653862436049.png

1653862017406.png
1653862436049.png
1653862670956.png
1653862670956.png
1653862670956.png
1653862436049.png
1653862436049.png
 

Excel Facts

Shade all formula cells
To shade all formula cells: Home, Find & Select, Formulas to select all formulas. Then apply a light fill color.
If you are running XL2010 or later versions, you can use Power Query to combine files.

 
Upvote 0
Solution

Forum statistics

Threads
1,223,705
Messages
6,173,996
Members
452,542
Latest member
Bricklin

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