UPdate value on sheet cells from textbox on userform

lumch

Board Regular
Joined
Jan 29, 2010
Messages
204
Hello, I have this code that transfers data to a sheet and creates a data base of : Name, DOB, Phone number, Insurance name, Insurance ID.



Dim strDataRange As Range
Dim keyRange As Range
Set strDataRange = Range("A1:h5000")
Set keyRange = Range("A1:h5000")
strDataRange.Sort Key1:=keyRange, Header:=xlYes
Dim tr As Worksheet
Set tr = Worksheets("Sheet16")
iRow = tr.Cells(Rows.Count, 1) _
.End(xlUp).Offset(1, 0).Row
tr.Cells(iRow, 1).Value = Me.TextBox1.Value
tr.Cells(iRow, 2).Value = Me.TextBox2.Value
tr.Cells(iRow, 3).Value = Me.TextBox22.Value
tr.Cells(iRow, 4).Value = Me.TextBox23.Value
tr.Cells(iRow, 5).Value = Me.TextBox17.Value
tr.Cells(iRow, 6).Value = Me.ComboBox15.Value
tr.Cells(iRow, 7).Value = Me.TextBox21.Value
tr.Cells(iRow, 8).Value = Me.TextBox32.Value


Then on this code, I am able to call all that information enter before (above code) and its populates on textboxes:

Private Sub ComboBox13_Change()
On Error Resume Next
Me.TextBox1.Value = Me.ComboBox13.Column(0)
Me.TextBox2.Value = Me.ComboBox13.Column(1)
Me.TextBox22.Value = Me.ComboBox13.Column(2)
Me.TextBox23.Value = Me.ComboBox13.Column(3)
Me.TextBox17.Value = Me.ComboBox13.Column(4)
Me.ComboBox15.Value = Me.ComboBox13.Column(5)
Me.TextBox21.Value = Me.ComboBox13.Column(6)
Me.TextBox32.Value = Me.ComboBox13.Column(7)
On Error GoTo 0
End Sub

With ComboBox13
.ColumnCount = 1
.ColumnWidths = "120"
.ColumnHeads = False
.RowSource = "Sheet16!A2:h5200"
End With

What I can't do or I need to do is, If the data change on any of these textboxes and I need to update the information such as : phone number or Insurance Id. How can I change it on those textboxes and press a command button to update that new data enter?

Thanks a lot
[FONT=Helvetica, Arial, Verdana, sans-serif]I have submitted this before , However I think I did not explain well[/FONT]
 
Understood, but we need to use the insurance id column as a unique id to make sure we update the data for that row.

Code:
Dim insidcol as string
insidcol = "D:D" 'or whatever column it is.
Set tr = Worksheets("Sheet16")
iRow = application.match(Me.TextBox32.Value,tr.range(insidcol),0)
'----now you have the row you need to update
Me.TextBox1.Value = tr.Cells(iRow, 1).Value
'...
'...
'...
The idea would be that the user would input an insurance ID somewhere on the userform, press a button and it would populate your userform with all the current data within the Excel sheet for that ID. Then the user could correct any data that needs corrected and press another button to save it over the data in the spreadsheet.
See example of this: http://rodericke.com/estuff


I took a look of the page you send me, Thanks, however it looks complicated, I did not know which part of the code I need, I'm gonna try yours in a separated command button that says "update info", Is this the way should be? thanks
 
Upvote 0

Excel Facts

Ambidextrous Undo
Undo last command with Ctrl+Z or Alt+Backspace. If you use the Undo icon in the QAT, open the drop-down arrow to undo up to 100 steps.
How are you populating the combobox that's being used to populate the textboxes?

like this

Private Sub ComboBox13_Change()
On Error Resume Next
Me.TextBox1.Value = Me.ComboBox13.Column(0)
Me.TextBox2.Value = Me.ComboBox13.Column(1)
Me.TextBox22.Value = Me.ComboBox13.Column(2)
Me.TextBox23.Value = Me.ComboBox13.Column(3)
Me.TextBox17.Value = Me.ComboBox13.Column(4)
Me.ComboBox15.Value = Me.ComboBox13.Column(5)
Me.TextBox21.Value = Me.ComboBox13.Column(6)
Me.TextBox32.Value = Me.ComboBox13.Column(7)
On Error GoTo 0
End Sub
 
Upvote 0
The sample you send me , I couldnt figure out how to make it work, Do you have any other idea? tx
 
Upvote 0

Forum statistics

Threads
1,223,236
Messages
6,170,912
Members
452,366
Latest member
TePunaBloke

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