ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Code seems limited by row number (https://www.excelbanter.com/excel-programming/408266-code-seems-limited-row-number.html)

Patrick C. Simonds

Code seems limited by row number
 
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


Jarek Kujawa[_2_]

Code seems limited by row number
 
to me the code works till the row of an active cell is not bigger than
the count of list elements


All times are GMT +1. The time now is 11:09 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com