ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Copy from file1 sheet1/file2 sheet1 last blank row (https://www.excelbanter.com/excel-programming/396118-copy-file1-sheet1-file2-sheet1-last-blank-row.html)

Tasha

Copy from file1 sheet1/file2 sheet1 last blank row
 
GCan someone please help me? I've looked at all the posts here regarding
doing this, but they don't seem to apply to what I want to do.

I need to copy all data except column headings in row 1 from workbook1,
Sheet1(consists of data in columns A-G and rows will vary by day) to
workbook2, Sheet1 in the last blank row available. Both files have the same
type of data, am just appending to workbook 1 daily. I've been doing this
manually, but know there has to be an easier way. Is there a way to do this
without opening workbook2? If not, that's fine, just thought I would see.
Thank you so much for your help!!!

Pranav Vaidya

Copy from file1 sheet1/file2 sheet1 last blank row
 
Hi Tasha,

Use the below macro. You can copy this in the source workbook from where you
want the data to be copied-

Dim myRange As Range
Dim mLastRow As Integer
Dim tLastRow As Integer
'find the last row in the current workbook
mLastRow = Range("A65000").End(xlUp).Row
'set the range to copy
Set myRange = Range("A2:G" & mLastRow)
'copy the data
myRange.Copy
'Open the target workbook
Workbooks.Open "C:\Test2.xls"
'Select the target worksheet
Sheets("Sheet1").Select
'find the last row to copy
tLastRow = Range("A65000").End(xlUp).Row + 1
'select the target cell
Range("A" & tLastRow).Select
'Copy the data
ActiveSheet.Paste
'close the target workbook with save changes
ActiveWorkbook.Close yes

This macro is tested and with inline comments to guide you.
Hope this helps.
--
Pranav Vaidya
VBA Developer
PN, MH-India
If you think my answer is useful, please rate this post as an ANSWER!!


"Tasha" wrote:

GCan someone please help me? I've looked at all the posts here regarding
doing this, but they don't seem to apply to what I want to do.

I need to copy all data except column headings in row 1 from workbook1,
Sheet1(consists of data in columns A-G and rows will vary by day) to
workbook2, Sheet1 in the last blank row available. Both files have the same
type of data, am just appending to workbook 1 daily. I've been doing this
manually, but know there has to be an easier way. Is there a way to do this
without opening workbook2? If not, that's fine, just thought I would see.
Thank you so much for your help!!!


Tasha

Copy from file1 sheet1/file2 sheet1 last blank row
 
Oh my Gosh, it works perfect!! I cannot thank you enough!!! And I really
really appreciate the play by play through the macro....I retain more when I
know what it is I am actually doing!!!

"Pranav Vaidya" wrote:

Hi Tasha,

Use the below macro. You can copy this in the source workbook from where you
want the data to be copied-

Dim myRange As Range
Dim mLastRow As Integer
Dim tLastRow As Integer
'find the last row in the current workbook
mLastRow = Range("A65000").End(xlUp).Row
'set the range to copy
Set myRange = Range("A2:G" & mLastRow)
'copy the data
myRange.Copy
'Open the target workbook
Workbooks.Open "C:\Test2.xls"
'Select the target worksheet
Sheets("Sheet1").Select
'find the last row to copy
tLastRow = Range("A65000").End(xlUp).Row + 1
'select the target cell
Range("A" & tLastRow).Select
'Copy the data
ActiveSheet.Paste
'close the target workbook with save changes
ActiveWorkbook.Close yes

This macro is tested and with inline comments to guide you.
Hope this helps.
--
Pranav Vaidya
VBA Developer
PN, MH-India
If you think my answer is useful, please rate this post as an ANSWER!!


"Tasha" wrote:

GCan someone please help me? I've looked at all the posts here regarding
doing this, but they don't seem to apply to what I want to do.

I need to copy all data except column headings in row 1 from workbook1,
Sheet1(consists of data in columns A-G and rows will vary by day) to
workbook2, Sheet1 in the last blank row available. Both files have the same
type of data, am just appending to workbook 1 daily. I've been doing this
manually, but know there has to be an easier way. Is there a way to do this
without opening workbook2? If not, that's fine, just thought I would see.
Thank you so much for your help!!!



All times are GMT +1. The time now is 04:51 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com