View Single Post
  #14   Report Post  
Dave Peterson
 
Posts: n/a
Default

I'm kind of confused about how you populated the listbox.

I used a range on sheet1 and this seemed to work ok.

Option Explicit
Dim myInputRng As Range
Private Sub CommandButton1_Click()
Unload Me
End Sub
Private Sub CommandButton2_Click()
Dim myRow As Long
With Me.ListBox1
If .ListIndex < 0 Then
Beep 'nothing to do
Else
myRow = myInputRng.Cells(1).Offset(.ListIndex).Row
MsgBox myRow & vbLf & .Value & vbLf & _
myInputRng.Cells(1).Offset(.ListIndex).Value
End If
End With
End Sub
Private Sub UserForm_Initialize()

With Worksheets("sheet1")
Set myInputRng = .Range("a2", .Cells(.Rows.Count, "A").End(xlUp))
End With

With Me.ListBox1
.List = myInputRng.Value
End With
End Sub



bach wrote:

Hi,

This is harder than i thought it would be, I have the listbox index
stored with +2 so that it matches the first bit of data on the sheet
(row2).

This is stored in a variable listSelect, how do i use this to select a
row and display the results

I am thinking that i would need to use this

ws.Cells(irow, 2).Value = UCase(Me.cboYourDeacon.Value)
but in reverse, but this used the irow which was generated to find the
last row.

I need irow to equal the row which i have attempted with

irow = ws.Cells(Rows(lstSelect & ":" & lstSelect))

which didn't work any idears.

Bach

--
bach
------------------------------------------------------------------------
bach's Profile: http://www.excelforum.com/member.php...o&userid=26134
View this thread: http://www.excelforum.com/showthread...hreadid=468634


--

Dave Peterson