Hi Folks,
Can someone please point out to me the error.
When i run the code below i get the runtime error 9 Subscript out of Range message and this line of code is higlighted.
I would be grateful if someone could tell me what is wrong with this code in order to get it working again.
MAIN CODE:
Thanks
Can someone please point out to me the error.
When i run the code below i get the runtime error 9 Subscript out of Range message and this line of code is higlighted.
Code:
lRow = wsTo.Cells(Rows.count, vData(0)).End(xlUp).Row
MAIN CODE:
Code:
Dim bSelected() As Boolean, iPtr As Integer, lCur As Long, lRow As Long
Dim R As Range
Dim vFrCols As Variant, vData() As Variant
Dim wsTo As Worksheet
If ActiveSheet.Name <> "Schedule 2" Then
MsgBox "Currently Active Sheet Is Not Warehouse Schedule"
Sheets("Schedule 2").Select
Exit Sub
End If
Set wsTo = Sheets("Priority List")
ReDim bSelected(0 To 0)
For Each R In Selection
lCur = R.Row
If UBound(bSelected) < lCur Then ReDim Preserve bSelected(0 To lCur)
bSelected(lCur) = True
Next R
vFrCols = Split(expression:="A,F,B,J,I", delimiter:=",")
ReDim vData(1 To UBound(vFrCols) + 1)
' lRow = 4 'This tells it where to place the information copied starting at row 5
lRow = wsTo.Cells(Rows.count, vData(0)).End(xlUp).Row 'finds the last row in column A (i.e. contents of vData(0) )
'and then tells it where to place the information copied starting at row 5
For lCur = 2 To UBound(bSelected)
If bSelected(lCur) = True Then
lRow = lRow + 1
For iPtr = 0 To UBound(vFrCols)
vData(iPtr + 1) = Cells(lCur, vFrCols(iPtr)).Value
Next iPtr
With Rows(lCur).Interior
.ColorIndex = 6
.Pattern = xlSolid
End With
wsTo.Range("B" & lRow, Cells(lRow, UBound(vData)).Address).Value = vData
End If
Next lCur
Thanks