View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
John Wilson John Wilson is offline
external usenet poster
 
Posts: 550
Default Visible Rows Indexing

Bernie,

The code to populate the list box is working.
I'm using code that I got from Tom (it's attached at the bottom)

The code to get the ListBox Index is working too
(also attached below)

After I do a filter, I end up with a number of visible rows.
For example, let's say that the visible rows are 5 (header row)
and rows 8, 10 & 12.
The List box populates perfectly with the code.
When I double click the list box, I pass the ListBox Index
to a public variable (RemindLBI_No) and open up another
user form. I then want to use that Index number to get the
row number of one of the visible rows so that I can populate
some text boxes on the second user form with values on
that row.

Forgetting everything I explained above and the code attached below,
what I'm looking to do is capture the row number of 1st, 2nd and 3rd
visible row via an integer.
If rows 8, 16 & 23 are the only rows visible, how can I plug the
number 1 into a line of code and return 1, plug 2 in and get 16
and plug 3 in and get 23????

Thanks,
John

Coding below:

'Populate the ListBox:
Dim rng As Range
On Error Resume Next
Set rng = Range(Cells(6, 1), Cells(Rows.Count,
1).End(xlUp)).SpecialCells(xlVisible)
On Error GoTo 0
If Not rng Is Nothing Then
For Each cell In rng
ListBox1.AddItem cell.Value
ListBox1.List(ListBox1.ListCount - 1, 1) = cell.Offset(0,
1)
ListBox1.List(ListBox1.ListCount - 1, 2) = cell.Offset(0,
2)
Next
End If

'Get the ListBox Index and open the second user form
Private Sub ListBox1_DblClick(ByVal Cancel As MSForms.ReturnBoolean)
RemindLBI_No = ListBox1.ListIndex
EditReminder.Show
End Sub

' Populate the second User Form. Need to be able to plug the index number
' in the right place to index down the visible rows only.
Private Sub UserForm_Activate()
With ActiveCell
nVisRow = Range(.Offset(RemindLBI_No), Cells(65536, .Column)) _
.SpecialCells(xlCellTypeVisible).Cells(1).Row
TextBox1.Value = Worksheets("Reminders").Range("A" & nVisRow)
TextBox2.Value = Worksheets("Reminders").Range("B" & nVisRow)
TextBox3.Value = Worksheets("Reminders").Range("C" & nVisRow)
End With
End Sub



Bernie Deitrick wrote:

John,

You need to include the code that populates your listbox for us to
troubleshoot it.

HTH,
Bernie
MS Excel MVP