Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get the size of a range in Excel

Tags:

Using VBA, is it possible to get the size of a given range in terms of pixels or units? (I don't care which unit as I am only using it to relate to other measurements with the same unit).

Thanks.

like image 558
Cameron Avatar asked Feb 10 '10 15:02

Cameron


People also ask

What is the formula for range in Excel?

Enter the formula =IF(A1:A10>5,"MAX") into cell B1. In cell B2, enter the formula =MIN(A1:A10). Subtract the two formulas by entering =B2-B1 into cell C1. You now have the range of your data.

How do I count a range of cells in Excel VBA?

To count rows using VBA, you need to define the range from which you want to count the rows and then use the count and rows property to get the count of the row from that range. You can also use a loop to count rows where you have data only.


1 Answers

The overall dimensions of a range are in its Width and Height properties.

Dim r As Range Set r = ActiveSheet.Range("A4:H12")  Debug.Print r.Width Debug.Print r.Height 
like image 136
Tomalak Avatar answered Sep 28 '22 03:09

Tomalak