P
Patrick C. Simonds
Can any one explain to me why this code will not run on any row beyond row
99?
I get the following error msg: "activecell row out of range or no list row
selected"
It works perfectly on row's 1 - 99.
Private Sub CommandButton1_Click()
Dim i As Long, nRow As Long, nLstIdx As Long
Dim rngList As Range
Dim aCols, aLstCols
Application.ScreenUpdating = False
aCols = Array(4, 5, 7, 8, 9, 10, 12, 13, 14, 15, 17, 18) '=
destination column number
aLstCols = Array(0, 4, 5, 13, 1, 6, 7, 14, 2, 8, 9, 15) ' = source
column number
Set rngList = Range(Me.ListBox1.RowSource)
nRow = ActiveCell.Row
nLstIdx = Me.ListBox1.ListIndex
If nRow > Me.ListBox1.ListCount Or nLstIdx = -1 Then
MsgBox "activecell row out of range or no list row selected"
Exit Sub
End If
For i = 0 To UBound(aCols)
With Cells(nRow, aCols(i))
.Value = ListBox1.List(nLstIdx, aLstCols(i))
.Font.ColorIndex = rngList(nLstIdx + 1, aLstCols(i) +
1).Font.ColorIndex
End With
Next
Application.ScreenUpdating = True
Unload Tuesday_Route_To_Cover
End Sub
99?
I get the following error msg: "activecell row out of range or no list row
selected"
It works perfectly on row's 1 - 99.
Private Sub CommandButton1_Click()
Dim i As Long, nRow As Long, nLstIdx As Long
Dim rngList As Range
Dim aCols, aLstCols
Application.ScreenUpdating = False
aCols = Array(4, 5, 7, 8, 9, 10, 12, 13, 14, 15, 17, 18) '=
destination column number
aLstCols = Array(0, 4, 5, 13, 1, 6, 7, 14, 2, 8, 9, 15) ' = source
column number
Set rngList = Range(Me.ListBox1.RowSource)
nRow = ActiveCell.Row
nLstIdx = Me.ListBox1.ListIndex
If nRow > Me.ListBox1.ListCount Or nLstIdx = -1 Then
MsgBox "activecell row out of range or no list row selected"
Exit Sub
End If
For i = 0 To UBound(aCols)
With Cells(nRow, aCols(i))
.Value = ListBox1.List(nLstIdx, aLstCols(i))
.Font.ColorIndex = rngList(nLstIdx + 1, aLstCols(i) +
1).Font.ColorIndex
End With
Next
Application.ScreenUpdating = True
Unload Tuesday_Route_To_Cover
End Sub