Note that there are some explanatory texts on larger screens.

plurals
  1. POFind cell location based on value then do something- User Forms VBA Excel
    text
    copied!<p>i have experience in programing, however, I am new to VBA. I have a user form that i am working on. This form has a Combo Box that has a list initialized to it. What i am trying to do is:</p> <p>*Get the ID Number value inputted by the user from the ComboBox *Take the value inputted by the user and find its match using a range of values from a worksheet (i.e. Worksheet.Range("ID_Number_List")) *Once it obtains it's match get the location of the cell that it matches * Off set the location of the cell by one column to get the Name that relates to the ID Number(Same Row) to set it to textBoxName.Value *Off set it two columns to get the telefone number that relates to the ID Number and set it to textboxTele.value</p> <p>I want this to happen as soon as a value is selected from the Combobox, so my question is does my code go in the combo box or does it go to the next text box? so as soon as the person tabs over to the next text box the code is automatically execute. i would like the code to fully execute without tabing over to the next box. </p> <p>This code is not complete but here is what i have (i didnt add the off set part i just did a test execution):</p> <pre><code>Dim ORIValue As String 'get value from combo_box Set ORIValue = COMBO_ORILIST.Value Dim cLoc As Range Dim cORIVal As Range 'worksheet with the ID information Dim ORISheetList As Worksheet Set ORISheetList = Worksheets("ORI_LIST") ' For Each cLoc In ORISheetList.Range("ORI_LIST") 'compare the input string from list- considering using Match function for this If StrComp(cLoc, ORIValue, vbTextCompare) Then TextBAgencyName.Value = "test" Else: Next cLoc End If </code></pre> <p>Let me know what you think. If i have to rewrite everything i will. </p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload