For lRow = 353 To 2 Step -1 what does this mean

andycreber

Board Regular
Joined
May 20, 2010
Messages
74
Office Version
  1. 2016
I am using this bit of code in my macro I found to nearly work but could someone please tell me what this means

For lRow = 353 To 2 Step -1

does it only go down to row 353?

I want it to work on columns B & C only, thanks

The full code is:
Code:
Dim lRow As Integer
Dim intCol As Long
Dim rngCell As Range, fn


Set fn = Application.WorksheetFunction


For intCol = 2 To 3
    For lRow = 353 To 2 Step -1
        Set rngCell = Cells(lRow, intCol)
        With rngCell
            .Value = fn.Substitute(rngCell.Value, Chr(160), Chr(32))
            .Value = Trim(rngCell.Value)
        End With
        If Len(rngCell) = 0 Then
            rngCell.Delete shift:=xlUp
        End If
        Set rngCell = Nothing
    Next lRow
Next intCol
 
Last edited by a moderator:

Excel Facts

Enter current date or time
Ctrl+: enters current time. Ctrl+; enters current date. Use Ctrl+: Ctrl+; Enter for current date & time.
It starts at the (last) row and works it way up.
Often used when deleting rows, since deleting rows would then make the macro miss/skip data not accounted for during the delete.
 
Upvote 0

Forum statistics

Threads
1,215,746
Messages
6,126,641
Members
449,325
Latest member
Hardey6ix

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