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

Can you AutoAverage in Excel?
There is a drop-down next to the AutoSum symbol. Open the drop-down to choose AVERAGE, COUNT, MAX, or MIN

Forum statistics

Threads
1,215,695
Messages
6,126,261
Members
449,307
Latest member
Andile

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