M
Ming
I am trying to copy a lot of data from a closed Excel file to current
Excel file using a piece of VBA code.
I tried "copy and paste",got the following code from Macro recording:
Sub Dataacquire()
Dim Row As Integer
Workbooks.Open Filename:="C:\temp\test.xls"
Row = Application.Count("A:A")
'find the total rows of non-empty data
Range("A1:A1000").Select
'I want to apply the "Row" value here but don't know how
Selection.Copy
Workbooks("test.xls").Close
Windows("Book2.xls").Activate
Range("A1").Select
ActiveSheet.Paste
End Sub
Is there a more efficient way to get data from a closed file?
For example, I can use a simple loop to copy data between WORKSHEETS
such as
..Worksheets("Sheet2").Cells(i,j)=.WorkSheets("Sheet1").Cells(i,j). Can
I do similar thing between different WORKBOOKS?
After I open the source file, which workbook will "With ThisWorkbook"
statement refer to,source file or current one?
Thanks for your help!
Excel file using a piece of VBA code.
I tried "copy and paste",got the following code from Macro recording:
Sub Dataacquire()
Dim Row As Integer
Workbooks.Open Filename:="C:\temp\test.xls"
Row = Application.Count("A:A")
'find the total rows of non-empty data
Range("A1:A1000").Select
'I want to apply the "Row" value here but don't know how
Selection.Copy
Workbooks("test.xls").Close
Windows("Book2.xls").Activate
Range("A1").Select
ActiveSheet.Paste
End Sub
Is there a more efficient way to get data from a closed file?
For example, I can use a simple loop to copy data between WORKSHEETS
such as
..Worksheets("Sheet2").Cells(i,j)=.WorkSheets("Sheet1").Cells(i,j). Can
I do similar thing between different WORKBOOKS?
After I open the source file, which workbook will "With ThisWorkbook"
statement refer to,source file or current one?
Thanks for your help!