79721452

Date: 2025-07-31 14:42:10
Score: 2.5
Natty:
Report link
Private Sub cmOp1_AfterUpdate()
    
    Dim comboBoxValue As String
    comboBoxValue = cmOp1.Text
    
    Dim i As Long
    For i = 1 To 2
    
        Dim textBoxValue As String
        textBoxValue = Me.Controls("Name" & i).Text
        
        If textBoxValue <> comboBoxValue Then
            GoTo ContinueLooping
        End If
        
        ' Update Hrs text
        Me.Controls("Hrs" & i).Text = "100"
        Exit For
        
ContinueLooping:
    Next i
    
End Sub

This code looks at the value in the changed combobox, and searches through the "Name" textboxes for that value. If that value is found, the corresponding "Hrs" textbox is updated to 100.


There is some confusion between what your question is asking (specially "randomly change"), and the clarification you provided under Black cat's answer. If I've misunderstood what you're trying to do, please let me know.


Finally, if you plan to ask more questions on StackOverflow, I suggest learning about Minimal Reproducible Examples. It will make it a lot easier for others to help you when your code works "out of the box".

Reasons:
  • Blacklisted phrase (1): StackOverflow
  • RegEx Blacklisted phrase (2.5): please let me know
  • Long answer (-1):
  • Has code block (-0.5):
  • Low reputation (0.5):
Posted by: TehDrunkSailor