Seems so simple, but I am not getting the expected result.
My attempt, simplified for illustration:
Sub myMacro2()
Dim intLastRow As Long
Dim intLastCol As Long
Dim numAve As Double
Dim i As Integer
intLastRow = ActiveSheet.UsedRange.Rows.Count
intLastCol = ActiveSheet.UsedRange.Columns.Count
For i = 1 To intLastRow Step 1
numAve = Application.WorksheetFunction.Average(Cells(i, 2), Cells(i, intLastCol))
MsgBox "Row: " & i & " Ave: " & numAve
Next i
End Sub
My data for this example (5 columns, populated from left to right), empty cells treated as NULL.
A 111
B 111
C 111 222 333 444
D 111 222
E 111 222 333
F 111 222
The msgBox returns "111" as the average value for each row.
I am pretty sure I am missing something fundamental or obvious, but it is eluding me.
Any suggestions, please?
.Average(.Range(.Cells(I, 2), .Cells(I, intLastCol))). That's assuming your range is correct. Note also the qualified range and cell objects.