Microsoft Excel Training Videos

Using a 'for' loop with the CurrentRegion property in Microsoft Excel


If you don't know the boundaries of the range you want to loop through, you can use the CurrentRegion property to return the range that surrounds the active cell.
For example, the following procedure, when run from a worksheet, loops through the range that surrounds the active cell, setting to 0 all values less than 0.01.
Sub RoundToZero3()
For Each c In ActiveCell.CurrentRegion.Cells
If c.Value < 0.01 Then c.Value = 0
Next
End Sub


Custom Search

Microsoft Excel Training Videos