ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   can someone explain what the below macro does (https://www.excelbanter.com/excel-programming/278279-can-someone-explain-what-below-macro-does.html)

aneurin

can someone explain what the below macro does
 
hi i found the below code that seaches col b for any cell that
contains the word verifiers and deletes the enrire row if found
but can someone explain how it does it
i understand most of it but i cant get my head round thr step -1 part

cheers


Sub del_row()
Dim rw As Integer
Dim Word As String
Word = "Verifiers"

For rw = 2000 To 2 Step -1
If InStr(2, ActiveSheet.Cells(rw, 2).Value, Word, vbTextCompare)
Then Cells(rw, 2).EntireRow.Delete
Next rw
End Sub

Bob L.

can someone explain what the below macro does
 
Step -1 just means to increment the counter by -1. So here it means start
the loop with row 2000 and count backwards (row 1999, 1998 etc) until row 2.
For more, Search VBA help for explanation of for next loops.

Bob L.


"aneurin" wrote in message
om...
hi i found the below code that seaches col b for any cell that
contains the word verifiers and deletes the enrire row if found
but can someone explain how it does it
i understand most of it but i cant get my head round thr step -1 part

cheers


Sub del_row()
Dim rw As Integer
Dim Word As String
Word = "Verifiers"

For rw = 2000 To 2 Step -1
If InStr(2, ActiveSheet.Cells(rw, 2).Value, Word, vbTextCompare)
Then Cells(rw, 2).EntireRow.Delete
Next rw
End Sub





All times are GMT +1. The time now is 10:32 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com