ComboBox_Click Event gets CurRow of Sheet but ComboBox_Change Event Does not allow Click_Event to Run it Properly

NimishK

Well-known Member
Joined
Sep 4, 2015
Messages
684
Basically Searching in Change Event does not allow Click_Event To run Smoothly. Don't Know Why.
By Clicking on Value in ComboBox1_click event to get the Row Works Perfect but COMPLETELY without Change_Event. Incorporated Change_Event to Search a value from Column A and to Select the Row.
So Want to get the Row Number with ComboBox_Change event and simultaneoulsy with ComboBox_Click event
Code:
Private Sub UserForm_Initialize()
ComboBox1.List = Worksheets("Sheet1").Range("A2").CurrentRegion.Offset(1).Value
End Sub


Private Sub ComboBox1_Click()
Dim curRow As Long
curRow = ComboBox1.ListIndex + 2
If idx <> -1 Then
         Worksheets("Sheet1").Rows(curRow).Select
    End If
End Sub


Private Sub ComboBox1_Change()
Dim i As Long
    With ComboBox1

       If Not IsArrow Then
       .List = Worksheets("Sheet1").Range("A2").CurrentRegion.Offset(1).Value

        If .ListIndex = -1 And Len(.Text) Then
            For i = .ListCount - 1 To 0 Step -1
                If InStr(1, .List(i), .Text, 1) = 0 Then .RemoveItem i
             Next i
            .DropDown
        End If
    End If
  If Me.ComboBox1.ListCount = 0 Then MsgBox "Sorry Not Found"
  End With
End Sub

Private Sub ComboBox1_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer)
IsArrow = KeyCode = vbKeyUp Or KeyCode = vbKeyDown
If KeyCode = vbKeyReturn Then ComboBox1.List = Worksheets("Sheet1").Range("A2").CurrentRegion.Offset(,1).Value
End Sub
NimishK
 
Last edited:

Excel Facts

Test for Multiple Conditions in IF?
Use AND(test, test, test, test) or OR(test, test, test, ...) as the logical_test argument of IF.
Realised and Gradually i need to move on and to resolve my Post #1 of this thread
Part 1
My column A shows following data
501 to 509
510
511
512
512
513
As i type 1 only it shows all the values with 1 ie
501, 510, 511, 512, 512,513

As i type 11 it shows 511. When 12 typed it shows 512, 512

1. Actually what i want is when typed 1 only and Pressed Enter: Msgbox "does not exist in the list"
When typed 11 it shows 511 but with 11 only and Enter pressed: Msgbox "It does not exist"
if 511 directly typed and Enter then Msgbox "Yes"

2. Also when typed 12 512 which is repeated dipslays twice. if 12 pressed and Enter Msgbox "Does not exist in the List"
Now Typed 512 it displays Twice. So Option of Dropwdown is Twice. How Can i know that i've selected 1st 512 or 2nd 512

Though mentioned in ComboBox1_Change() If Me.ComboBox1.ListCount = 0 Then MsgBox "Does Not Exisits in the List". Probably this syntax is not enough for what i want ?

Would appreciate if anyone has worked for similar situation ahd help me. or give me the ref: of thread will also be helpful

Thanks in Advance
 
Last edited:
Upvote 0

Forum statistics

Threads
1,215,096
Messages
6,123,074
Members
449,094
Latest member
mystic19

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top