PDA

View Full Version : Solved: help getting listindex from listbox



edjohns
09-21-2012, 09:03 AM
hi,

i cannot seem to get this working. the objective is to delete the contents of a certain row based on what the user is selecting from a listbox


Private Sub CommandButton1_Click()
Dim nRow As Double
Dim record As Range
Dim sheet As Worksheet

Set sheet = ThisWorkbook.Worksheets("TABLES")

If tbl_incidencia.ListIndex = -1 Then
' DISPLAY ERROR MESSAGE IF NOTHING IS SELECTED
Else

nRow = tbl_incidencia.ListIndex
Set record = sheet.Range(Cells(nRow, 4), Cells(nRow, 11))
record.Select
' CLEAR CONTENTS FROM SELECTION

End If
End Sub

getting "application defined or object defined error"
i dont understand why i get this error

i feel like an idiot bumping on almost every little code snippet lately... i really appreciate you guys helping me.:banghead:

edjohns
09-23-2012, 02:33 PM
found the problem.

in case you're curious, had to refer the list box like userform.listbox.property