I have a non fixed set of data that may vary in rows and columns.
I intend to use VBA to search the whole dataset and round off all cells with numbers to a specified decimal place. (or rounded to nearest 100s or 10s too)
I have the following code:
Sub roundthissheet()
Dim cell As Range, rng As Range
rng = Range("A1", ActiveCell.SpecialCells(xlLastCell)).Select
For Each cell In rng.cells
If cell.Value <> "" And IsNumeric(cell.Value) Then
cell.Value = Round(cell.Value, -2)
End If
Next cell
End Sub
However, my if statement does not seem to run at all and I encounter the error message "Object variable or With block variable not set"
How shall I proceed with regards to this error?