Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Deleting/Adding/Changing values based on ComboBox1 Value
On a userform I have combobox1, Textbox1, Textbox2, and
Textbox3 and commandbutton1. The values of the 3 textboxes depend on the value of combobox1. Values of combobox1 are pulled from range M2:M100. The user will select a value from the combobox. When he/she selects a value from the combobox, the textboxes will populate with corresponding values from 3 different ranges. Textbox1 pulls in data from range P2:P100. Textbox2 pulls in data from range Q2:Q100. Textbox3 pulls in data from range R2:R100. The user can then add/change/delete values in the 3 textboxes. When the user makes the desired changes, he/she hits the Update commandbutton1. I need a code that will make the changes to the appropriate corresponding cell in the corresponding range that the textbox references. Thank you Todd |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Deleting/Adding/Changing values based on ComboBox1 Value
How are the textboxes populated to begin with?
Assuming that they're based on something like the Combobox ListIndex: CommandButton1_Click() Dim nIndex As Long nIndex = ComboBox1.ListIndex With ThisWorkbook.Sheets("MyDataSheet") .Range("P2").Offset(nIndex, 0).Value = TextBox1.Value .Range("Q2").Offset(nIndex, 0).Value = TextBox2.Value .Range("R2").Offset(nIndex, 0).Value = TextBox3.Value End With 'Other Stuff - e.g. Unload, Hide End Sub In article , "Todd Huttenstine" wrote: On a userform I have combobox1, Textbox1, Textbox2, and Textbox3 and commandbutton1. The values of the 3 textboxes depend on the value of combobox1. Values of combobox1 are pulled from range M2:M100. The user will select a value from the combobox. When he/she selects a value from the combobox, the textboxes will populate with corresponding values from 3 different ranges. Textbox1 pulls in data from range P2:P100. Textbox2 pulls in data from range Q2:Q100. Textbox3 pulls in data from range R2:R100. The user can then add/change/delete values in the 3 textboxes. When the user makes the desired changes, he/she hits the Update commandbutton1. I need a code that will make the changes to the appropriate corresponding cell in the corresponding range that the textbox references. Thank you Todd |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Deleting/Adding/Changing values based on ComboBox1 Value
Here is how I have it all linked.
With Worksheets(4) Set rng = .Range("M2:M100") For Each cell In rng If cell.Text = ComboBox1.Value Then TextBox1.Value = .Cells(cell.Row, 16).Value TextBox2.Value = .Cells(cell.Row, 17).Value TextBox3.Value = .Cells(cell.Row, 18).Value Exit For End If Next End With -----Original Message----- How are the textboxes populated to begin with? Assuming that they're based on something like the Combobox ListIndex: CommandButton1_Click() Dim nIndex As Long nIndex = ComboBox1.ListIndex With ThisWorkbook.Sheets("MyDataSheet") .Range("P2").Offset(nIndex, 0).Value = TextBox1.Value .Range("Q2").Offset(nIndex, 0).Value = TextBox2.Value .Range("R2").Offset(nIndex, 0).Value = TextBox3.Value End With 'Other Stuff - e.g. Unload, Hide End Sub In article , "Todd Huttenstine" wrote: On a userform I have combobox1, Textbox1, Textbox2, and Textbox3 and commandbutton1. The values of the 3 textboxes depend on the value of combobox1. Values of combobox1 are pulled from range M2:M100. The user will select a value from the combobox. When he/she selects a value from the combobox, the textboxes will populate with corresponding values from 3 different ranges. Textbox1 pulls in data from range P2:P100. Textbox2 pulls in data from range Q2:Q100. Textbox3 pulls in data from range R2:R100. The user can then add/change/delete values in the 3 textboxes. When the user makes the desired changes, he/she hits the Update commandbutton1. I need a code that will make the changes to the appropriate corresponding cell in the corresponding range that the textbox references. Thank you Todd . |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
Deleting/Adding/Changing values based on ComboBox1 Value
Todd,
Just reverse it? ..Cells(cell.Row, 16).Value = TextBox1.Value Regards, Anders Silven "Todd" skrev i meddelandet ... Here is how I have it all linked. With Worksheets(4) Set rng = .Range("M2:M100") For Each cell In rng If cell.Text = ComboBox1.Value Then TextBox1.Value = .Cells(cell.Row, 16).Value TextBox2.Value = .Cells(cell.Row, 17).Value TextBox3.Value = .Cells(cell.Row, 18).Value Exit For End If Next End With -----Original Message----- How are the textboxes populated to begin with? Assuming that they're based on something like the Combobox ListIndex: CommandButton1_Click() Dim nIndex As Long nIndex = ComboBox1.ListIndex With ThisWorkbook.Sheets("MyDataSheet") .Range("P2").Offset(nIndex, 0).Value = TextBox1.Value .Range("Q2").Offset(nIndex, 0).Value = TextBox2.Value .Range("R2").Offset(nIndex, 0).Value = TextBox3.Value End With 'Other Stuff - e.g. Unload, Hide End Sub In article , "Todd Huttenstine" wrote: On a userform I have combobox1, Textbox1, Textbox2, and Textbox3 and commandbutton1. The values of the 3 textboxes depend on the value of combobox1. Values of combobox1 are pulled from range M2:M100. The user will select a value from the combobox. When he/she selects a value from the combobox, the textboxes will populate with corresponding values from 3 different ranges. Textbox1 pulls in data from range P2:P100. Textbox2 pulls in data from range Q2:Q100. Textbox3 pulls in data from range R2:R100. The user can then add/change/delete values in the 3 textboxes. When the user makes the desired changes, he/she hits the Update commandbutton1. I need a code that will make the changes to the appropriate corresponding cell in the corresponding range that the textbox references. Thank you Todd . |
#5
Posted to microsoft.public.excel.programming
|
|||
|
|||
Deleting/Adding/Changing values based on ComboBox1 Value
Thank you.
Thats exactly what I needed. Todd -----Original Message----- How are the textboxes populated to begin with? Assuming that they're based on something like the Combobox ListIndex: CommandButton1_Click() Dim nIndex As Long nIndex = ComboBox1.ListIndex With ThisWorkbook.Sheets("MyDataSheet") .Range("P2").Offset(nIndex, 0).Value = TextBox1.Value .Range("Q2").Offset(nIndex, 0).Value = TextBox2.Value .Range("R2").Offset(nIndex, 0).Value = TextBox3.Value End With 'Other Stuff - e.g. Unload, Hide End Sub In article , "Todd Huttenstine" wrote: On a userform I have combobox1, Textbox1, Textbox2, and Textbox3 and commandbutton1. The values of the 3 textboxes depend on the value of combobox1. Values of combobox1 are pulled from range M2:M100. The user will select a value from the combobox. When he/she selects a value from the combobox, the textboxes will populate with corresponding values from 3 different ranges. Textbox1 pulls in data from range P2:P100. Textbox2 pulls in data from range Q2:Q100. Textbox3 pulls in data from range R2:R100. The user can then add/change/delete values in the 3 textboxes. When the user makes the desired changes, he/she hits the Update commandbutton1. I need a code that will make the changes to the appropriate corresponding cell in the corresponding range that the textbox references. Thank you Todd . |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Deleting rows based on column values | New Users to Excel | |||
Deleting rows based on values in a a cell in the row | New Users to Excel | |||
Adding up various columns based on the value of one changing cell | Excel Worksheet Functions | |||
Adding numerical values based on multiple values in another column | Excel Worksheet Functions | |||
3 textbox values based on value in ComboBox1 | Excel Programming |