Mar 07 2018
02:40 AM
- last edited on
Jul 25 2018
09:52 AM
by
TechCommunityAP
Mar 07 2018
02:40 AM
- last edited on
Jul 25 2018
09:52 AM
by
TechCommunityAP
Hey guys. Could you please support me to get VBA code for copying data from Worbook X to first empty rowe in workbook Y
Mar 07 2018 04:34 AM - edited Mar 07 2018 04:53 AM
SolutionHello Mohamed,
Here is the piece of code. This may not be the best effective way, but something that can do the job for you.
' you can amend the A1:Z100 range to whatever is your actual data range
You should put this code in a module of workbook from which you want the data to be copied from.
it will copy from Sheet1 of thisworkbook into the path and file name and sheet Sheettopasteto
Sub CopyfromThisworkbookToANother()
Workbooks.Open ("C:\Documents\ExcelFiletoPasteDataTo.xlsx") ' you can amend this path and file name to you actual path and file name
ThisWorkbook.Sheets("Sheet1").Range("A1:Z100").Copy Workbooks("ExcelFiletoPasteDataTo.xlsx").Sheets("Sheettopasteto").Range("A" & Rows.Count).End(xlUp).Offset(1, 0)
End Sub
Mar 07 2018 05:14 AM
Thanks you so much Jamil for your quick replay. But unfortunately this code still not working in my sheet
Mar 07 2018 05:21 AM
did you rename the object names from the code to the actual names of your workbooks objects?
or simply you copied and pasted the code i posted?
Can you tell me what is the name of sheet you are copying from?
what is the range to copy?
what is the workbook name to paste to?
and what is the sheet name to paste to?
which column it should be pasted to?
is the workbook you are pasting to, an open workbook, it is saved in a directory folder?
Mar 07 2018 05:35 AM
Can you tell me what is the name of sheet you are copying from? Sheet1
what is the range to copy? A1:BB1000
what is the workbook name to paste to? Y.xlsx
and what is the sheet name to paste to? Sheet1
which column it should be pasted to? column1
is the workbook you are pasting to, an open workbook, it is saved in a directory folder? yes
But you didn't ask about the workbook name which i need to copy date from. name is X.xlsx
Mar 07 2018 06:21 AM
My last question.
what is the full path/directory string where the WOrkbook Y.xlsx is saved?
also your workbook X needs to be saved as Macro Enabled workbook which is xlsm
so that the code can be saved there.
Mar 07 2018 08:47 PM
the 2 files is are saved in same folder
D:\VBA\X.xlsx
D:\VBA\Y.xlsx
Mar 08 2018 01:28 AM
Thanks Jamil. It's working now. Thanks for your time and support
Mar 08 2018 01:51 AM
You are welcome. I am glad I was able to help. Thanks for feedback.
Mar 08 2018 01:54 AM
Jamil. One more thing. If i want to create the code but in the sheet which I need to copy to. Is that possible?
Mar 08 2018 01:58 AM
Yes,
simply reverse it like this
Sub CopyfromThisworkbookToANother() Workbooks.Open ("C:\Documents\ExcelFiletoPasteDataTo.xlsx") ' you can amend this path and file name to you actual path and file name Workbooks("ExcelFiletoPasteDataTo.xlsx").Sheets("Sheetcopyfrom").Range("A1:Z100").Copy ThisWorkbook.Sheets("Sheettopasteto").Range("A" & Rows.Count).End(xlUp).Offset(1, 0) End Sub
Mar 07 2018 04:34 AM - edited Mar 07 2018 04:53 AM
SolutionHello Mohamed,
Here is the piece of code. This may not be the best effective way, but something that can do the job for you.
' you can amend the A1:Z100 range to whatever is your actual data range
You should put this code in a module of workbook from which you want the data to be copied from.
it will copy from Sheet1 of thisworkbook into the path and file name and sheet Sheettopasteto
Sub CopyfromThisworkbookToANother()
Workbooks.Open ("C:\Documents\ExcelFiletoPasteDataTo.xlsx") ' you can amend this path and file name to you actual path and file name
ThisWorkbook.Sheets("Sheet1").Range("A1:Z100").Copy Workbooks("ExcelFiletoPasteDataTo.xlsx").Sheets("Sheettopasteto").Range("A" & Rows.Count).End(xlUp).Offset(1, 0)
End Sub