Guest_imported
New member
- Jan 1, 1970
- 0
My problem is this: I,m making a macro where i copy different columns of differents workbooks to new workbook, and what i,m doing it's ok, but my problem is that the number of rows to select in another worksheets is relative, always is changing, because the workbooks are actualized, every week, so i can,t select the exactly range every time thet i run the macro, one thing that i think that happened is that the control of the macro lost, because i try to select one range in another workbook.
I hope that you can help me, thenk you., the moment that i select one cell in another workbook i can,t select the range with a cycle.
Example:
For i = 0 To UBound(WBName)
Set xlWB = xlApp.Workbooks.Open(WBPath & WBName(i), False)
xlWB.Sheets(WSName(i)).Select
xlWB.Sheets(WSName(i)).Range("a1".Select
While xlWB.Sheets(WSName(i)).ActiveCell <> ""
contador = contador + 1
ActiveCell.Offset(1, 0).Select
Wend
cpyRnge = Array("A1:C & contador"
'cpyRnge = Array("xlWB.sheets(WSName(i)).Range(selection, Selection.End(xlDown)).Select"
xlWB.Sheets(WSName(i)).Range(cpyRnge(i)).Copy
Sheets("SideCombo".Range(pstRnge(i)).Select
ActiveSheet.Paste
xlWB.Close
Next i
I hope that you can help me, thenk you., the moment that i select one cell in another workbook i can,t select the range with a cycle.
Example:
For i = 0 To UBound(WBName)
Set xlWB = xlApp.Workbooks.Open(WBPath & WBName(i), False)
xlWB.Sheets(WSName(i)).Select
xlWB.Sheets(WSName(i)).Range("a1".Select
While xlWB.Sheets(WSName(i)).ActiveCell <> ""
contador = contador + 1
ActiveCell.Offset(1, 0).Select
Wend
cpyRnge = Array("A1:C & contador"
'cpyRnge = Array("xlWB.sheets(WSName(i)).Range(selection, Selection.End(xlDown)).Select"
xlWB.Sheets(WSName(i)).Range(cpyRnge(i)).Copy
Sheets("SideCombo".Range(pstRnge(i)).Select
ActiveSheet.Paste
xlWB.Close
Next i