ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Combobox - to specific row? (https://www.excelbanter.com/excel-programming/303048-combobox-specific-row.html)

NorTor[_3_]

Combobox - to specific row?
 
Hello,

I have a userform with a combobox and some textboxes.
The combobox gets its list from a range of rows in one of the sheets.

The user selects a value in the combobox, and can fill the other
textfields. When the user presses the OK button in the form, I want
the values of the textboxes to be put to specific columns on the row
corresponding to the row that is selected in the combobox.

Please help me how to solve this!

I should also mention that the range is dynamic, so it its resized
with another row (eg from A1:A50 to A1:A51). The problem is to have
values placed in eg B15 and C15 if the user selects the value from
A15 in the combobox.


Hope for help :-)
NorTor


kkknie[_155_]

Combobox - to specific row?
 
Try something like this:

Code
-------------------
Sub CommandButton_Click()

dim r as Range

For Each r in Range("A1:A" & Range("A65536").End(xlUp).Row
If r.Value = Combo1.Text Then
Range("B" & r.Row).Value = Text1.Text
Range("C" & r.Row).Value = Text2.Text
Exit For
End If

Next

End Su
-------------------

It basically searches the A column until it finds the same thin
selected in the combobox, then puts the text box values into columns
and C of the same row.



--
Message posted from http://www.ExcelForum.com


NorTor[_3_]

Combobox - to specific row?
 
Thank you so much for you reply, I will try it right away :)


Regards
NorTor



On Thu, 1 Jul 2004 12:26:44 -0500, kkknie
wrote:

Try something like this:

Code:
--------------------
Sub CommandButton_Click()

dim r as Range

For Each r in Range("A1:A" & Range("A65536").End(xlUp).Row
If r.Value = Combo1.Text Then
Range("B" & r.Row).Value = Text1.Text
Range("C" & r.Row).Value = Text2.Text
Exit For
End If

Next

End Sub
--------------------

It basically searches the A column until it finds the same thing
selected in the combobox, then puts the text box values into columns B
and C of the same row.

K


---
Message posted from http://www.ExcelForum.com/




All times are GMT +1. The time now is 02:54 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com