Hi
I have got a macro which basically does the following :
- finds and selects all the numbers in one column using special cells (column contains numbers and some text comments)
- copies all those numbers and corresponding codes located in another column(Offset(0, -3)to another sheet
-creates a variant array : vaUpload = Range("a1:n" & iLastRow).Value from copied&pasted data
What i would like to do is to bypass that copy and paste step and put all the numbers and codes directly into my array after they get selected.
The only quick way of doing this i know (vArray = Range("a1:n" & iLastRow).Value) does not work on the multiple selected cells - the example range adress of selected cells would be somthing like " $b$1:$b$2,$b$7,$b$9:$b$15 "
Does anyone know how to put this into array in a quick way?
Hope it makes sense - i would be very grateful for all suggestions.
Thanks
-----------------------------------------------------------
the code :
'select numeric constants from my column
Selection.SpecialCells(xlCellTypeConstants, 1).Select
'get the address of selected cells
'how to get this into my array without copy&paste?
rngCodes = Selection.Offset(0, -3).Address
rngPrices = Selection.Address
'
'go to upload sheet
With Sheets("Upload")
.Visible = True
.Select
End With
'clear prv run
Cells.ClearContents
'copy codes
Sheets(sMySheet).Range(rngCodes).Copy
Range("a2").Select
ActiveSheet.Paste
'copy prices
Sheets(sMySheet).Range(rngPrices).Copy
Range("f2").Select
ActiveSheet.Paste
'find last record
iLastRow = Range("A65536").End(xlUp).Row
'create an array
vaUpload = Range("a1:n" & iLastRow).Value
I have got a macro which basically does the following :
- finds and selects all the numbers in one column using special cells (column contains numbers and some text comments)
- copies all those numbers and corresponding codes located in another column(Offset(0, -3)to another sheet
-creates a variant array : vaUpload = Range("a1:n" & iLastRow).Value from copied&pasted data
What i would like to do is to bypass that copy and paste step and put all the numbers and codes directly into my array after they get selected.
The only quick way of doing this i know (vArray = Range("a1:n" & iLastRow).Value) does not work on the multiple selected cells - the example range adress of selected cells would be somthing like " $b$1:$b$2,$b$7,$b$9:$b$15 "
Does anyone know how to put this into array in a quick way?
Hope it makes sense - i would be very grateful for all suggestions.
Thanks
-----------------------------------------------------------
the code :
'select numeric constants from my column
Selection.SpecialCells(xlCellTypeConstants, 1).Select
'get the address of selected cells
'how to get this into my array without copy&paste?
rngCodes = Selection.Offset(0, -3).Address
rngPrices = Selection.Address
'
'go to upload sheet
With Sheets("Upload")
.Visible = True
.Select
End With
'clear prv run
Cells.ClearContents
'copy codes
Sheets(sMySheet).Range(rngCodes).Copy
Range("a2").Select
ActiveSheet.Paste
'copy prices
Sheets(sMySheet).Range(rngPrices).Copy
Range("f2").Select
ActiveSheet.Paste
'find last record
iLastRow = Range("A65536").End(xlUp).Row
'create an array
vaUpload = Range("a1:n" & iLastRow).Value