VBA property UsedRange.Rows.Count

Ricardo Caicedo

New Member
Joined
Aug 21, 2014
Messages
43
I need a slight variation for the property UsedRange .rows.count</SPAN>

With this property I can count the number of rows in a spreadsheet; however I need to count the rows after a “variable” number of rows had been used with data that I do not need. I know where the “real data” starts; the program goes where the header is located, so in the next row the data starts.(The rows between this and the data can have empty)</SPAN>

Let me describe an example</SPAN>


A</SPAN>
B</SPAN>
C</SPAN>
1</SPAN>
PPPPPP</SPAN>
PPPPPP</SPAN>
PPPPPP</SPAN>
2</SPAN>
PPPPPP</SPAN>
PPPPPP</SPAN>
PPPPPP</SPAN>
3</SPAN>



4</SPAN>



5</SPAN>



…..</SPAN>



……</SPAN>
Header</SPAN>


25</SPAN>
REAL DATA 1</SPAN>
REAL DATA 2</SPAN>
REAL DATA 3</SPAN>
26</SPAN>
REAL DATA 4</SPAN>
REAL DATA 5</SPAN>
REAL DATA 6</SPAN>

<TBODY>
</TBODY>


In this file I have the info that I need from the rows 25 forward (inclusive if it is just one row) so I need to count the rows where my data really are located, for this example starting in cell A25 (this location is variable).</SPAN>

So I need to know where the data starts (asking where the current cursor is) and how many rows de data are. NOTE: in the data region there are not empty rows.</SPAN>
 

Excel Facts

Formula for Yesterday
Name Manager, New Name. Yesterday =TODAY()-1. OK. Then, use =YESTERDAY in any cell. Tomorrow could be =TODAY()+1.
Maybe

Code:
ActiveCell.CurrentRegion.Rows.Count

If the header above the real data is constant then you could use Find instead of looking for it and positioning the cursor there.

Code:
Sheets("Your Sheet").Cells.Find("Header").Offset(1).CurrentRegion.Rows.Count -1
 
Last edited:
Upvote 0

Forum statistics

Threads
1,203,625
Messages
6,056,384
Members
444,862
Latest member
more_resource23

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top