Dear Excel Experts,
I have a VBA below which works fine but when there is no value in column I to Column J it will give a value of #DIV/0! in computing the average What shall I do to convert it to blank? Kindly help me please. See code below
Thanks,
Nhinx
I have a VBA below which works fine but when there is no value in column I to Column J it will give a value of #DIV/0! in computing the average What shall I do to convert it to blank? Kindly help me please. See code below
VBA Code:
Private Sub Worksheet_Activate()
Row = 8 'row of description
Column = 6 'column of description
Dim sheet As Worksheet
Do Until ThisWorkbook.ActiveSheet.Cells(Row, Column).Value <> ""
Row = Row + 1
Loop
Do Until ThisWorkbook.ActiveSheet.Cells(Row, Column).Value = "TOTAL"
If ThisWorkbook.ActiveSheet.Cells(Row, Column).Value <> "" Then
ThisWorkbook.ActiveSheet.Cells(Row, 12).Value = "=AVERAGE(RC[-3]:RC[-1]" & ")"
ElseIf ThisWorkbook.ActiveSheet.Cells(Row, Column).Value = "" Then
ThisWorkbook.ActiveSheet.Cells(Row, 12).Value = ""
End If
Row = Row + 1
Loop
End Sub
Thanks,
Nhinx