Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Find range of the column where the active cell is

I have 1000 columns each containing 30 rows of data in excel. I want to write a Macro that will find the average of each column. I want to use Range("A31:ALL31").Value = "=AVERAGE(current column's range)" but i don’t know how to get the range of the active column. Is there a way to do that?

>Solution :

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

Not 100% sure exactly what you want but this code will put a formula in row 31 from column A to column ALL (that is a column), that averages the rows above starting at row 2.

    Range("A31:ALL31").FormulaR1C1 = "=AVERAGE(R2C:R[-1]C)"

Here’s an example of the formula(s) that code will produce.

=AVERAGE(A$1:A30)
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading