If only run first line and skip the others

Capa7md

New Member
Joined
Aug 21, 2023
Messages
11
Office Version
  1. 365
  2. 2021
Platform
  1. Windows
Hi i want ti edit my data by using if and when i run the code it just go to first line and skip the others

Private Sub CommandButton1_Click()
Dim LastRow As Long
Dim NewRow As Long
LastRow = Sheet1.Cells(Rows.Count, 1).End(xlUp).Row
For NewRow = 3 To LastRow
If Sheet1.Cells(NewRow, 1) = CInt(Me.TextBox6) Then
Sheet1.Cells(NewRow, 2) = Me.TextBox1
Sheet1.Cells(NewRow, 3) = Me.TextBox2
End If
Next NewRow



End Sub
 
@Capa7md , when you step through your code, just before the IF statement executes, what are the Values of NewRow and LastRow?

@Capa7md , when you step through your code, just before the IF statement executes, what are the Values of NewRow and LastRow?
The lastrow is 7 and newrow will be the row which i want to make an update on ir and it will take the value of row if the if was true
 
Upvote 0

Excel Facts

Fastest way to copy a worksheet?
Hold down the Ctrl key while dragging tab for Sheet1 to the right. Excel will make a copy of the worksheet.

Forum statistics

Threads
1,223,705
Messages
6,173,985
Members
452,540
Latest member
haasro02

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