I am trying to look through a large amount of data in a single worksheet and change the formatting for all cells containing percentages. I can do it using a simply For Each loop on each cell, but it's slow. I understand I can probably speed it up by writing to an array first, but I'm clumsy.
Clearly I'm not using NumberFormat correctly on an object, but I can't figure out how to do that.Sub Test10() Dim TempRange As Variant Dim iRow As Long Dim iColumn As Long Dim PercentFormat As String TempRange = Sheets(1).UsedRange.Value For iRow = LBound(TempRange) To UBound(TempRange) For iColumn = LBound(TempRange) To UBound(TempRange) PercentFormat = TempRange(iRow, iColumn).NumberFormat '==== throws error, "object required" If PercentFormat = "0.00%" Then PercentFormat = "0%" End If Next iColumn Next iRow Sheets(1).UsedRange.Value = TempRange End Sub
I also suspect I'm not describing LBound and UBound correctly.
Thanks