Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Im sorry but I dont have any code for this so far, however
I do have code at the bottom of this post for when I click the 3 Option Buttons and ComboBox1 auto-populates with data from the corresponding columns on Sheet2 Range A2:C52. I have a userform that contains TextBox1, TextBox2, TextBox3, OptionButton1, OptionButton2, OptionButton3, and ComboBox1. I have a table of data on Sheet2 Range A2:C52. When I select an option button, it auto-populates ComboBox1 with the corresponding data in the columns in Range A2:C52. OptionButton1 is corresponding with data in columnA, OptionButton2 is corresponding with data in columnB, and OptionButton3 is corresponding with data in columnC. Now, I need a code that will match the value in ComboBox1 with a value in Range A2:C52 on Sheet2. If a match is NOT found, then do nothing(this will never happen because anything that is in ComboBox1 will be found in the range). If there IS a match with the value in ComboBox1 (which there always will be), then I need for the code to put the corresponding data in the corresponding TextBoxes. The way it will do this is as follows: If the match is in a cell in Column A, then I need it to put the data in that cell in Column A into TextBox1, and then the corresponding data in the other 2 cells in the columns into the corresponding 2 Textboxes. If the match is in a cell in Column B, then I need it to put the data in that cell in Column B into TextBox2 and then the corresponding data in the other 2 cells in the columns into the corresponding 2 Textboxes. If the match is in a cell in Column C, then I need it to put the data in that cell in Column C into TextBox3 and then the corresponding data in the other 2 cells in the columns into the corresponding 2 Textboxes. Here is some info that may help... Below is the code I am using for when I click the 3 Option Buttons and ComboBox1 auto-populates with data from the corresponding columns on Sheet2 Range A2:C52... Private Sub OptionButton1_Click() cLastRow = Worksheets(2).Cells(Rows.Count, "A").End (xlUp).Row With ComboBox1 .Clear For i = 3 To cLastRow + 1 If Cells(i, "A") < "" Then .AddItem Worksheets(2).Cells(i - 1, "A").Value End If Next i .ListIndex = 0 End With End Sub Private Sub OptionButton2_Click() cLastRow = Worksheets(2).Cells(Rows.Count, "B").End (xlUp).Row With ComboBox1 .Clear For i = 3 To cLastRow + 1 If Cells(i, "B") < "" Then .AddItem Worksheets(2).Cells(i - 1, "B").Value End If Next i .ListIndex = 0 End With End Sub Private Sub OptionButton3_Click() cLastRow = Worksheets(2).Cells(Rows.Count, "C").End (xlUp).Row With ComboBox1 .Clear For i = 3 To cLastRow + 1 If Cells(i, "C") < "" Then .AddItem Worksheets(2).Cells(i - 1, "C").Value End If Next i .ListIndex = 0 End With End Sub Thank you Todd Huttenstine |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
use value in texbox to search through worksheet | Excel Discussion (Misc queries) | |||
How do I copy only sub-totalled values - without any detail? | Excel Worksheet Functions | |||
Combobox populating based on Option Button | Excel Programming | |||
How many CR's in a multi line texbox | Excel Programming | |||
ComboBox Values | Excel Programming |