Hi
Anyone
Can you get the Row Number on basis of Index of Combolist ?
The reason is that when in Combo1.Change() event
when i type the data in combo change i get respective values of its data in text boxes but what happens is
the same value gets overwritten in the Defined First row of the Worksheet. Which i dont want to happen.
What i want is when i search data in combobox it should goto that row number of the worksheet where that respective data is there in respective columns
so how to get the row number
How to get row number with below combo1.change by which i type the values in combobox and respective values get updated in text boxes and in that particular row for which i was searching the value
Thanks
NimishK
Anyone
Can you get the Row Number on basis of Index of Combolist ?
The reason is that when in Combo1.Change() event
when i type the data in combo change i get respective values of its data in text boxes but what happens is
the same value gets overwritten in the Defined First row of the Worksheet. Which i dont want to happen.
What i want is when i search data in combobox it should goto that row number of the worksheet where that respective data is there in respective columns
so how to get the row number
Code:
Private Sub UserForm_Initialize()
Dim myArray
Dim intRow As Long
Dim lastRow As Long
curRec = 1
curRow = 2
With Sheets("Sheet1")
.Activate
userfrm1.text1.Text .Text = .Cells(2, 2).Value
userfrm1.text2.Text Text = .Cells(2, 1).Value
userfrm1.text3.Text .Text = .Cells(2, 9).Value
intRow = .Cells(Rows.Count, 1).End(xlUp).Row
myArray = .Range("A2:J" & intRow).Value
userfrm1combo1.List() = .Range(Cells(2, 2), Cells(intRow, 2)).Value
End With
End sub
How to get row number with below combo1.change by which i type the values in combobox and respective values get updated in text boxes and in that particular row for which i was searching the value
Code:
Private Sub combo1_Change()
Dim IdWs As Worksheet
Set IdWs = Sheets("Sheet1")
Dim myRanges As Range
Set myRanges = Sheets("Sheet1").Range("a2:J25")
Dim idx As Long
idx = combo1.ListIndex
If idx <> -1 Then
With Worksheets("Sheet1")
userfrm1.text1.Text = .Range("A" & idx + 2).Value
userfrm1.text2.Text = .Range("B" & idx + 2).Value
userfrm1.text3.Text = .Range("C" & idx + 2).Value
End with
End if
End Sub
NimishK
Last edited: