I am trying to find the max value of a group of seperate cells in VBA.
Here is my code;
Dim r As Integer
Dim c As Integer
r = 3
c = 3
While r <= iNameRows
While c <= iColCount
ActiveSheet.Cells(r, c).Select
If ActiveCell.Value = Application.WorksheetFunction.Max(ActiveCell.Value, ActiveCell.Offset(0, 3).Value, ActiveCell.Offset(0, 6).Value, ActiveCell.Offset(0, 9).Value, ActiveCell.Offset(0, 12).Value, ActiveCell.Offset(0, 15).Value, ActiveCell.Offset(0, 18).Value, ActiveCell.Offset(0, 21).Value) Then
With ActiveSheet
.Range(.Cells(r, c), .Cells(r, c + 2)).Select
End With
Selection.Font.Bold = True
End If
c = c + 3
Wend
r = r + 1
Wend
I'm getting a run-time error (1004) when it's trying to resolve the max value, I think because some of the tested cells are empty.
Would greatly appreciate help finding a workaround.
Thanks,
Mike D
Here is my code;
Dim r As Integer
Dim c As Integer
r = 3
c = 3
While r <= iNameRows
While c <= iColCount
ActiveSheet.Cells(r, c).Select
If ActiveCell.Value = Application.WorksheetFunction.Max(ActiveCell.Value, ActiveCell.Offset(0, 3).Value, ActiveCell.Offset(0, 6).Value, ActiveCell.Offset(0, 9).Value, ActiveCell.Offset(0, 12).Value, ActiveCell.Offset(0, 15).Value, ActiveCell.Offset(0, 18).Value, ActiveCell.Offset(0, 21).Value) Then
With ActiveSheet
.Range(.Cells(r, c), .Cells(r, c + 2)).Select
End With
Selection.Font.Bold = True
End If
c = c + 3
Wend
r = r + 1
Wend
I'm getting a run-time error (1004) when it's trying to resolve the max value, I think because some of the tested cells are empty.
Would greatly appreciate help finding a workaround.
Thanks,
Mike D