Hi there,
I need to copy a range from hundreds workbooks to one spreadsheet. In each workbook, there are 3 columns that I need to copy.
I wrote this :
It works well,
The problem is that every 13 workbooks I need to move about 5 columns to the right.
So the way I found is :
I have to copy this several times and to change manually the column. It works but it's not elegant (effective).
I tried : Range(cells(a,b),cells(c,d)) but it doesn't work in this case.
Do you have any idea ?
Thanks in advance,
Johann
I need to copy a range from hundreds workbooks to one spreadsheet. In each workbook, there are 3 columns that I need to copy.
I wrote this :
Code:
For i = 1 To 13
Workbooks.Open Filename:=ThisWorkbook.Path & "\Meter" & j & "-" & i & ".csv", ReadOnly:=True
Workbooks("Book1.xlsm").Sheets("Meter-1-2-3-4").Range("A" & incrow, "C" & incrow + 95) = Workbooks("Meter" & j & "-" & i & ".csv").Sheets("Meter" & j & "-" & i).Range("A2:C97").Value
incrow = incrow + 96
Workbooks("Meter" & j & "-" & i & ".csv").Close SaveChanges:=False
Next i
It works well,
The problem is that every 13 workbooks I need to move about 5 columns to the right.
So the way I found is :
Code:
j = 1
For i = 1 To 13
Workbooks.Open Filename:=ThisWorkbook.Path & "\Meter" & j & "-" & i & ".csv", ReadOnly:=True
Workbooks("Book1.xlsm").Sheets("Meter-1-2-3-4").Range([B]"A" & incrow, "C" & incrow + 95[/B]) = Workbooks("Meter" & j & "-" & i & ".csv").Sheets("Meter" & j & "-" & i).Range("A2:C97").Value
incrow = incrow + 96
Workbooks("Meter" & j & "-" & i & ".csv").Close SaveChanges:=False
Next i
j = j + 1
incrow = 2
For i = 1 To 13
Workbooks.Open Filename:=ThisWorkbook.Path & "\Meter" & j & "-" & i & ".csv", ReadOnly:=True
Workbooks("Book1.xlsm").Sheets("Meter-1-2-3-4").Range([B]"F" & incrow, "H" & incrow + 95[/B]) = Workbooks("Meter" & j & "-" & i & ".csv").Sheets("Meter" & j & "-" & i).Range("A2:C97").Value
incrow = incrow + 96
Workbooks("Meter" & j & "-" & i & ".csv").Close SaveChanges:=False
Next i
I have to copy this several times and to change manually the column. It works but it's not elegant (effective).
I tried : Range(cells(a,b),cells(c,d)) but it doesn't work in this case.
Do you have any idea ?
Thanks in advance,
Johann