2.Using For with IF else statement more fun and very helpful while completing repeated tasks in Excel..
Place a Command Button and add following code and in Excel add some value’s as below image.
Sub foreachloop()
Dim i As Long
Dim datarng As Long
With Worksheets("sheet1")
datarng = .Cells(.Rows.Count, "A").End(xlUp).Row
End With
For i = datarng To 1 Step -1
If Cells(i, 1).Value = "b" Then
Rows(i).Delete
End If
Next
End Sub
Note: Above code If Cells(i, 1).Value = "b" Then Change the value as you want to Find.
Output.Click the VBA button and see Excel Vba Deleted all the "b" in "A column.
Explanation: As we Defined VB to find b in a column of "A" and delete matching rows,
Below is the video tutorial.
Do like this Page, ? Please give your Email id Sign up for Daily News Letter...
Fastest Way to Find matching Values or Names and Delete Rows in Excel VBA.
Reviewed by Unknown
on
21:45
Rating:
No comments: