Hi,
I need to achieve the following:
1. insert an ActiveX listbox (single select, 4 columns) in the worksheet (Sheet1)
2. populate the listbox with a range in another sheet (sheet2)
3. after populating the list, whenever the user clicks on a row, a userform should pop-up with all the values in the 4 columns of the listbox in 4 different textboxes
4. user may want to edit the data, which may then be committed to the data sheet (sheet2) and refreshed in the listbox as well.
I am stuck at the 3rd step. Whenever I try to access the listbox range, the following error is generated:
The code that I am using is:Run-time error '1004':
Method 'Range' of object '_Worksheet' failed
Is my approach wrong? Or some problem with my coding? Please help.![]()
Private Sub myList_Click() Dim v1, v2, v3 As String Dim rng As Range Set rng = Range(myList.ListFillRange) v1 = myList.Value v2 = rng.Offset(myList.ListIndex, 1).Resize(1, 1).Value v3 = rng.Offset(myList.ListIndex, 2).Resize(1, 1).Value myForm.myTxt1.Value = v1 myForm.myTxt2.Value = v2 myForm.myTxt3.Value = v3 myForm.Show End Sub
Peace,
Shivboy











LinkBack URL
About LinkBacks
Register To Reply
Bookmarks