Copy data from current work to another

Sushil Gaikwad Posts 1 Registration date Tuesday February 11, 2014 Status Member Last seen February 11, 2014 - Feb 11, 2014 at 06:49 AM
 Sush - Feb 14, 2014 at 07:00 AM
Hi All,

Please can you help me with the VBA code which copies columns from current active workbook to another closed workbook at the end of rows... bcoz my closed workbook has lot of data with same details of members

My Data is

Name Address Age User
Sushil PCMC 21 SSC

1 reply

TrowaD Posts 2900 Registration date Sunday September 12, 2010 Status Moderator Last seen October 4, 2022 523
Feb 11, 2014 at 11:13 AM
Hi Sushil,

The following code will copy the data from the active workbook (columns A:D minus the header row). Then a closed workbook of your choosing will be opened. Copied data will be pasted in the first available row. Workbook will be closed and changes will be saved.

Sub RunMe()
Dim lRow As Integer

lRow = Range("A1").End(xlDown).Row

Range("A2:D" & lRow).Copy
Workbooks.Open "C:\MyFiles\Test.xls" 'Change file path to match yours
Range("A" & Rows.Count).End(xlUp).Offset(1, 0).PasteSpecial
ActiveWorkbook.Close SaveChanges:=True

Application.CutCopyMode = False
End Sub

Best regards,
That was really help full , Thank you very much its great