Update excel based on userform text box change

sivakumar123

New Member
Joined
Jul 26, 2012
Messages
21
Office Version
  1. 365
Platform
  1. Windows
Hi,

I have a text box which populates values from a range.
The text box is locked by default.
Once user clicks on an edit button, user will be able to change the value in the text box.
And after changing, once user clicks on one Save button, I need the new value to be updated in the excel sheet in the exact position.
Code:
Private Sub Members_Click()
ContactForm.teamName.Text = ""
Dim myCell As Variant, myIndex As Integer
Dim teamRng As Range, nameRng As Range
Set nameRng = ContactWorkBook.ActiveSheet.Range("myName")
Set teamRng = ContactWorkBook.ActiveSheet.Range("teamName")
myIndex = 0
For Each myCell In nameRng.Cells
    myIndex = myIndex + 1
    If myCell = Members.Text Then
       
       ContactForm.editTeam.Enabled = True '[I]The Edit button will be enabled here[/I]
       ContactForm.teamName.Value = teamRng(myIndex)
       If IsEmpty(teamRng(myIndex)) Then
          ContactForm.teamName.Value = "NA"
       End If
    End If
Next

As mentioned above, when user clicks an Edit button, the textbox teamName will be editable, and user can change values in it.
There is also another Save button. I want the exact position in the excel sheet to be updated when user clicks save button in user form.

Best Regards
Sivakumar

Note : This was posted in another forum but has not been answered yet. PFB the link.
Update excel based on userform text box update
 
Hi sivakumar

this is sateesh, am new to vba and userforms.
i am also faceing same problem, actully am done my task up to Add, search data. now i want how to edit/change data and edited data will saved as same cell. in my code when ever edit button press previous data erased. i don't want to erased all fields. just display all details if any changes, text will saved as same cell.
my code is
Private Sub CommandButton5_Click()


Range("A2").Select
row_number = 0
Do
DoEvents
row_number = row_number + 1
item_in_review = Sheets("Sheet1").Range("A" & row_number)
If item_in_review = TextBox1.Text Then
UserForm1.editTextbox2.Enabled = True
UserForm.editTextbox2 = TextBox2.Text






Sheets("Sheet1").Range("B" & row_number) = TextBox2.Text
'Sheets("Sheet1").Range("C" & row_number) = ComboBox1.Text
'Sheets("Sheet1").Range("D" & row_number) = TextBox3.Text
'Sheets("Sheet1").Range("E" & row_number) = TextBox4.Text
'Sheets("Sheet1").Range("F" & row_number) = TextBox5.Text
'Sheets("Sheet1").Range("G" & row_number) = TextBox6.Text
'Sheets("Sheet1").Range("H" & row_number) = TextBox7.Text
'Sheets("Sheet1").Range("I" & row_number) = TextBox8.Text
'Sheets("Sheet1").Range("j" & row_number) = UserForm2.TextBox2.Text
'Sheets("Sheet1").Range("k" & row_number) = UserForm2.TextBox2.Text
'Sheets("Sheet1").Range("l" & row_number) = UserForm2.TextBox3.Text
'Sheets("Sheet1").Range("m" & row_number) = UserForm2.TextBox4.Text
'Sheets("Sheet1").Range("n" & row_number) = UserForm2.TextBox5.Text
'Sheets("Sheet1").Range("o" & row_number) = UserForm2.TextBox6.Text
'Sheets("Sheet1").Range("p" & row_number) = UserForm2.TextBox7.Text
'Sheets("Sheet1").Range("q" & row_number) = UserForm2.TextBox8.Text
End If
Loop Until item_in_review = ""


End Sub


Thanks for advance



Hi,

I have a text box which populates values from a range.
The text box is locked by default.
Once user clicks on an edit button, user will be able to change the value in the text box.
And after changing, once user clicks on one Save button, I need the new value to be updated in the excel sheet in the exact position.
Code:
Private Sub Members_Click()
ContactForm.teamName.Text = ""
Dim myCell As Variant, myIndex As Integer
Dim teamRng As Range, nameRng As Range
Set nameRng = ContactWorkBook.ActiveSheet.Range("myName")
Set teamRng = ContactWorkBook.ActiveSheet.Range("teamName")
myIndex = 0
For Each myCell In nameRng.Cells
    myIndex = myIndex + 1
    If myCell = Members.Text Then
       
       ContactForm.editTeam.Enabled = True '[I]The Edit button will be enabled here[/I]
       ContactForm.teamName.Value = teamRng(myIndex)
       If IsEmpty(teamRng(myIndex)) Then
          ContactForm.teamName.Value = "NA"
       End If
    End If
Next

As mentioned above, when user clicks an Edit button, the textbox teamName will be editable, and user can change values in it.
There is also another Save button. I want the exact position in the excel sheet to be updated when user clicks save button in user form.

Best Regards
Sivakumar

Note : This was posted in another forum but has not been answered yet. PFB the link.
Update excel based on userform text box update
 
Upvote 0
Hi sivakumar

this is sateesh, am new to vba and userforms.
i am also faceing same problem, actully am done my task up to Add, search data. now i want how to edit/change data and edited data will saved as same cell. in my code when ever edit button press previous data erased. i don't want to erased all fields. just display all details if any changes, text will saved as same cell.
my code is
Private Sub CommandButton5_Click()


Range("A2").Select
row_number = 0
Do
DoEvents
row_number = row_number + 1
item_in_review = Sheets("Sheet1").Range("A" & row_number)
If item_in_review = TextBox1.Text Then

Sheets("Sheet1").Range("B" & row_number) = TextBox2.Text
'Sheets("Sheet1").Range("C" & row_number) = ComboBox1.Text
'Sheets("Sheet1").Range("D" & row_number) = TextBox3.Text
'Sheets("Sheet1").Range("E" & row_number) = TextBox4.Text
'Sheets("Sheet1").Range("F" & row_number) = TextBox5.Text
'Sheets("Sheet1").Range("G" & row_number) = TextBox6.Text
'Sheets("Sheet1").Range("H" & row_number) = TextBox7.Text
'Sheets("Sheet1").Range("I" & row_number) = TextBox8.Text
'Sheets("Sheet1").Range("j" & row_number) = UserForm2.TextBox2.Text
'Sheets("Sheet1").Range("k" & row_number) = UserForm2.TextBox2.Text
'Sheets("Sheet1").Range("l" & row_number) = UserForm2.TextBox3.Text
'Sheets("Sheet1").Range("m" & row_number) = UserForm2.TextBox4.Text
'Sheets("Sheet1").Range("n" & row_number) = UserForm2.TextBox5.Text
'Sheets("Sheet1").Range("o" & row_number) = UserForm2.TextBox6.Text
'Sheets("Sheet1").Range("p" & row_number) = UserForm2.TextBox7.Text
'Sheets("Sheet1").Range("q" & row_number) = UserForm2.TextBox8.Text
End If
Loop Until item_in_review = ""
End Sub


i think u understand my problem.
Thanks for advance



Hi,

I have a text box which populates values from a range.
The text box is locked by default.
Once user clicks on an edit button, user will be able to change the value in the text box.
And after changing, once user clicks on one Save button, I need the new value to be updated in the excel sheet in the exact position.
Code:
Private Sub Members_Click()
ContactForm.teamName.Text = ""
Dim myCell As Variant, myIndex As Integer
Dim teamRng As Range, nameRng As Range
Set nameRng = ContactWorkBook.ActiveSheet.Range("myName")
Set teamRng = ContactWorkBook.ActiveSheet.Range("teamName")
myIndex = 0
For Each myCell In nameRng.Cells
    myIndex = myIndex + 1
    If myCell = Members.Text Then
       
       ContactForm.editTeam.Enabled = True '[I]The Edit button will be enabled here[/I]
       ContactForm.teamName.Value = teamRng(myIndex)
       If IsEmpty(teamRng(myIndex)) Then
          ContactForm.teamName.Value = "NA"
       End If
    End If
Next

As mentioned above, when user clicks an Edit button, the textbox teamName will be editable, and user can change values in it.
There is also another Save button. I want the exact position in the excel sheet to be updated when user clicks save button in user form.

Best Regards
Sivakumar

Note : This was posted in another forum but has not been answered yet. PFB the link.
Update excel based on userform text box update
 
Upvote 0

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