Hello,
I would like to modify my code below to count columns and rows from a different range. Currently, the code below only reads from A1 of my data table. My data table starts at F7 with n columns and y rows. Each time I run the macro it does not recognise the range but only from A1.
Could you help to modify this code to read for a defined range?
Thanks in advance.
Dim iColumnCount As IntegerPlease Login or Register to view this content.
Dim lRowCount As Long
Dim iCol As Integer
Dim dAverage As Double
Worksheets(2).Activate
' Count number of columns and rows in use...
iColumnCount = ActiveSheet.UsedRange.Columns.Count
lRowCount = ActiveSheet.UsedRange.Rows.Count
' Cycle through each non-empty column...
For iCol = 1 To iColumnCount
' Use the Average and StDev Excel functions to
' calculate values for each column...
dAverage = WorksheetFunction.Average(Columns(iCol))
' Place results below existing data...
Cells(lRowCount + 2, iCol).Value = dAverage
Next iCol
End SubPlease Login or Register to view this content.
Bookmarks