UPDATING VALUES POPULATED IN THE LIST BOX WITH TEXT BOX AND SAME GETS UPDATED IN THE SHEET.

mahendar

New Member
Joined
Mar 6, 2021
Messages
1
Office Version
  1. 2019
Platform
  1. Windows
  2. Mobile
  3. Web
I HAVE THE ATTACHED THE CODE BELOW,
WHILE AMENDING THE EXISTING VALUES IN THE EXCEL SHEET USING LISTBOX FOR SLECTION TO SHOW THE VALUES IN THE TEXT BOX AND THEN UPDATING OR AMENDING VALUES.
MY CODE DOES THE AMENDMENT TO THE EXACT ROW BUT ALSO UPDATES THE SAME IN ROW 1. KINDLY HELP ?

Private Sub CMDUPDATE_Click()

Sheet2.Unprotect PASSWORD:="XXXX"
Dim x As Long
Dim y As Long
x = Sheet2.Range("A" & Rows.Count).End(xlUp).Row
For y = 2 To x
If Sheet2.Cells(y, 1).Value = Me.ListBox1.Column(0, 1) Then
Sheet2.Cells(y, 1).Value = TextBox1.Value
Sheet2.Cells(y, 2).Value = TextBox2.Value
Sheet2.Cells(y, 3).Value = TextBox3.Value
Sheet2.Cells(y, 4).Value = TextBox4.Value
Sheet2.Cells(y, 5).Value = TextBox5.Value
Sheet2.Cells(y, 6).Value = TextBox6.Value
Sheet2.Cells(y, 7).Value = TextBox7.Value
End If
Next y
Unload Me
CMDADD.Show
Sheet2.Protect PASSWORD:="XXXX"
ThisWorkbook.Save
End Sub
 

Excel Facts

Return population for a City
If you have a list of cities in A2:A100, use Data, Geography. Then =A2.Population and copy down.

Forum statistics

Threads
1,216,773
Messages
6,132,643
Members
449,739
Latest member
tinkdrummer

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