ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Deleting/Adding/Changing values based on ComboBox1 Value (https://www.excelbanter.com/excel-programming/285337-deleting-adding-changing-values-based-combobox1-value.html)

Todd Huttenstine[_2_]

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

J.E. McGimpsey

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


todd

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

.


Anders S[_2_]

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

.


Todd Huttenstine[_2_]

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

.



All times are GMT +1. The time now is 06:04 PM.

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