Adding Data in textBox in multiple columns by selecting comboBox

fazil1980

New Member
Joined
Feb 28, 2023
Messages
3
Office Version
  1. 2019
Platform
  1. Windows
Hello Everyone,
i am having some trouble in excel if anyone can help me out,

Now the scenario is. in column A we have Owner's Name which are also duplicating in Column D to H.
now in excel vba I have created a userform with a combo box, textbox and save button.
ComboBox is a list of owners.
textbox we have to write Plate number for car.
when press save button the plate number should add in columns D to H according to the selection of combo box.

Thank you
 

Attachments

  • Image 1.jpg
    Image 1.jpg
    69.9 KB · Views: 17
  • Image 2.jpg
    Image 2.jpg
    223.5 KB · Views: 18
  • Image 3.jpg
    Image 3.jpg
    99.2 KB · Views: 18

Excel Facts

Spell Check in Excel
Press F7 to start spell check in Excel. Be careful, by default, Excel does not check Capitalized Werds (whoops)
Hi and welcome to MrExcel.

when press save button the plate number should add in columns D to H according to the selection of combo box.
Try this:

VBA Code:
Private Sub CommandButton1_Click()
  Dim f As Range
  If lstCar.ListIndex > -1 Then
    Set f = Sheet1.Range("A1:H1").Find(lstCar.Value, , xlValues, xlWhole, , , False)
    If Not f Is Nothing Then
      Sheet1.Cells(Rows.Count, f.Column).End(3)(2).Value = txtCar.Value
    End If
  Else
    MsgBox "Enter Owner"
    lstCar.SetFocus
  End If
End Sub
 
Upvote 0
Solution
Hi and welcome to MrExcel.


Try this:

VBA Code:
Private Sub CommandButton1_Click()
  Dim f As Range
  If lstCar.ListIndex > -1 Then
    Set f = Sheet1.Range("A1:H1").Find(lstCar.Value, , xlValues, xlWhole, , , False)
    If Not f Is Nothing Then
      Sheet1.Cells(Rows.Count, f.Column).End(3)(2).Value = txtCar.Value
    End If
  Else
    MsgBox "Enter Owner"
    lstCar.SetFocus
  End If
End Sub
Yes, That's work Great thank you...
 
Upvote 0
Yes, That's work Great thank you...
The marked solution has been changed accordingly. In your future questions, please mark the post as the solution that actually answered your question, instead of your feedback message as it will help future readers. No further action is required for this thread.
 
Upvote 1

Forum statistics

Threads
1,216,566
Messages
6,131,437
Members
449,652
Latest member
ylsteve

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