PDA

View Full Version : [SOLVED] Dividing a column by a range of numbers



fitzanna
11-03-2016, 12:37 PM
While (ActiveCell.Value > 0)
While (ActiveCell.Value > 0)
colTotal = colTotal + ActiveCell.Value
ActiveCell.Offset(1, 0).Select
Wend
ActiveCell.Offset(1, 0).Value = colTotal
avgSales = colTotal / Range("A" & Rows.Count).End(xlUp).Row
colTotal = 0
currentCol = currentCol + 1
ActiveSheet.Cells(firstRow, currentCol).Select
Wend


I'm trying to compute average sales for each column, without using the average function itself. I correctly get each column total but I fail to get the colTotal to divide by the number in each column. Is there something I'm doing wrong here? The part I highlighted is the problem I believe. Is my count function wrong? Any help would be appreciated.

Kenneth Hobs
11-03-2016, 01:39 PM
If A1 is the column title, then the row count would be at least one more than it should.

fitzanna
11-03-2016, 03:06 PM
Thanks Kenneth! I managed to tweak it a bit and I got it working.

Cheers