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

Workdays for a market open Mon, Wed, Friday?
Yes! Use "0101011" for the weekend argument in NETWORKDAYS.INTL or WORKDAY.INTL. The 7 digits start on Monday. 1 means it is a weekend.
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,222,018
Messages
6,163,429
Members
451,837
Latest member
gmc

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