|
-
Apr 21st, 2005, 12:10 PM
#1
Thread Starter
Hyperactive Member
Get number of rows with data in a Range in Excel
My excel sheet looks like this
row 1 to row 150 have data and formating
row 151 to row 1600 have formating only
I need to find out the last row with DATA ONLY in Excel, however when I use the code below the count shows 1600 - all rows that have cell formating (backcolor etc) applied even if those cells have no data in them.
I also tried these with same problem:
VB Code:
ws.Cells.SpecialCells(xlCellTypeLastCell).row
xlApp.ActiveCell.SpecialCells(xlLastCell).Address(RowAbsolute:=False)
ws.UsedRange.Rows.Count
ActiveCell.SpecialCells(xlLastCell).row
How can I get the count of all the rows with data only.
-
Apr 21st, 2005, 12:16 PM
#2
Re: Get number of rows with data in a Range in Excel
You could try using the const. xlCellTypeBlanks. Cells with formatting may or may not be considered blank.
I cant remember, but the const. xlCellTypeSameFormatConditions will get you the cells with the same formats,
this may also help.
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Apr 21st, 2005, 12:21 PM
#3
Thread Starter
Hyperactive Member
Re: Get number of rows with data in a Range in Excel
Thanks RobDog888 I'll try that.
Could you help me with this one as well? I'm stuck.
http://www.vbforums.com/showthread.p...ht=Excel+array
-
Apr 21st, 2005, 11:38 PM
#4
Addicted Member
Re: Get number of rows with data in a Range in Excel
You can also do this:
VB Code:
Dim topCel As Range, bottomCel As Range
Dim NoOfRows As Integer, a As Integer
'Count entries
With ActiveSheet
Set topCel = .Range("A1").
Set bottomCel = .Cells((65536), topCel.Column).End(xlUp)
If bottomCel.Row <= topCel.Row Then
Exit Sub
End If
NoOfRows = .Range(topCel, bottomCel).Rows.Count
End With
Last edited by D-niss; Apr 25th, 2005 at 05:13 PM.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|