ComboBox1 value to auto populate TextBox1

Patriot2879

Well-known Member
Joined
Feb 1, 2018
Messages
1,259
Office Version
  1. 2010
Platform
  1. Windows
Hello good afternoon, hope you can help me please. I have the code below where i have made a module called 'GetDataNow' and linked that with the Combobox1, but i get an error with the code and when i select a name in combobox1, textbox1 does not populate the value from 'Fixer Info' sheet Row D2 to last row. hope you can help please?
VBA Code:
Option Explicit

Dim id As String, i As Long, j As Integer, flag As Boolean

Sub GetDataNow()
   Dim Rw As Variant
   If Len(UserForm2.ComboBox1.Value) > 0 Then
      
      flag = False
      id = UserForm2.ComboBox1.Value
      Rw = Application.Match(id, Sheets("Fixer Info").Range("A2:A56"), 0)
      
      If Not IsError(Rw) Then
         flag = True
         For j = 4
            UserForm2.Controls("ComboBox" & j).Value = ThisWorkbook.Worksheets("Fixer Info").Cells(Rw, j).Value
         Next j
      End If
      
      If flag = False Then
         For j =  4
            UserForm2.Controls("ComboBox" & j).Value = ""
         Next j
      End If
      
   Else
   End If
End Sub
 

Excel Facts

Waterfall charts in Excel?
Office 365 customers have access to Waterfall charts since late 2016. They were added to Excel 2019.
Hello good afternoon, hope you can help me please. I have the code below where i have made a module called 'GetDataNow' and linked that with the Combobox1, but i get an error with the code and when i select a name in combobox1, textbox1 does not populate the value from 'Fixer Info' sheet Row D2 to last row. hope you can help please?
VBA Code:
Option Explicit

Dim id As String, i As Long, j As Integer, flag As Boolean

Sub GetDataNow()
   Dim Rw As Variant
   If Len(UserForm2.ComboBox1.Value) > 0 Then
     
      flag = False
      id = UserForm2.ComboBox1.Value
      Rw = Application.Match(id, Sheets("Fixer Info").Range("A2:A56"), 0)
     
      If Not IsError(Rw) Then
         flag = True
         For j = 4
            UserForm2.Controls("ComboBox" & j).Value = ThisWorkbook.Worksheets("Fixer Info").Cells(Rw, j).Value
         Next j
      End If
     
      If flag = False Then
         For j =  4
            UserForm2.Controls("ComboBox" & j).Value = ""
         Next j
      End If
     
   Else
   End If
End Sub
I have also tried a different code but this didnt work either hope you can help please?
VBA Code:
Private Sub ComboBox1_AfterUpdate()
   Dim Fnd As Range
  
   Set Fnd = ThisWorkbook.Sheets("Fixer Info").Range("A:A").Find(TextBox2.Value, , , xlWhole, , , False, , False)
   If Not Fnd Is Nothing Then
      TextBox1.Value = Fnd.Offset(, 4).Value
   End If
  
End Sub
 
Upvote 0
Have you tried finding ComboBox1.Value instead of TextBox2.Value and using a Fnd Offset of 3 columns instead of 4 ?
 
Upvote 0
Solution

Forum statistics

Threads
1,223,903
Messages
6,175,284
Members
452,630
Latest member
OdubiYouth

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