Appending a file using VBA

buffalo

Board Regular
Joined
Jun 19, 2003
Messages
183
Appending a file using VBA

Hi,

Suppose I have two files. Q:\BLOTTER and Q:\TEST

How would append Q:\TEST with all the rows from Q:\BLOTTER?

Suppose Q:\TEST ends at row 20.

I would like Q:\BLOTTER to be copied to Q:\TEST from row 22 onwards.

Thanks
 

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.
assuming both files are open;
try
Code:
Sub test()
Dim wb1 As Workbook, wb2 As Workbook
Dim sh1 As Worksheet, sh2 As Worksheet
Dim lr As Long
Set wb1 = ThisWorkbook
Set wb2 = Workbooks("BLOTTER.xls")
Set sh1 = wb1.Sheets(1)
Set sh2 = wb2.Sheets(1)
Application.ScreenUpdating = False
Application.CutCopyMode = False
sh1.Range("a" & Rows.Count).End(xlUp).Offset(1).Value = "temp_value"
sh2.UsedRange.Copy
With sh1.Range("a" & Rows.Count).End(xlUp).Offset(1)
    .PasteSpecial xlPasteValues
End With
With sh1.Columns("a")
Set c = .Find("temp_value", , , xlWhole)
If Not c Is Nothing Then c.ClearContents
End With
Application.CutCopyMode = True
Application.ScreenUpdating = False
End Sub
 
Upvote 0

Forum statistics

Threads
1,213,536
Messages
6,114,215
Members
448,554
Latest member
Gleisner2

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