Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default VBA : Number of Blank Cells in a Range

How to get the number of Blanks rows in a range in VBA
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Number of Blank Cells in a Range

application.countblank(range("A1:H10"))

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"Sanka" wrote in message
...
How to get the number of Blanks rows in a range in VBA



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,885
Default Number of Blank Cells in a Range

Hi
try
msgbox application.countblank(activesheet.range("A1:A100" ))

or
msgbox application.countblank(selection)


--
Regards
Frank Kabel
Frankfurt, Germany


Sanka wrote:
How to get the number of Blanks rows in a range in VBA

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Number of Blank Cells in a Range

If the rng contains either blanks or constant values
Sub CountBlankRows()
Dim rng As Range, rng1 As Range, rng2 As Range
Set rng = Range("A1:Z100")
Set rng1 = Intersect(rng, ActiveSheet.UsedRange)
If Not rng1 Is Nothing Then
NonUsedRows = rng.Rows.Count - rng1.Rows.Count
On Error Resume Next
Set rng2 = rng1.SpecialCells(xlConstants).EntireRow
On Error GoTo 0
If rng2 Is Nothing Then
nrow = 0
Else
nrow = Intersect(rng2, Columns(1)).Count
End If
MsgBox NonUsedRows + _
(rng1.Rows.Count - nrow)
Else
MsgBox rng.Rows.Count
End If

End Sub

--
Regards,
Tom Ogilvy


"Sanka" wrote in message
...
How to get the number of Blanks rows in a range in VBA



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Number of Blank Cells in a Range

I interpreted your question to be what you wrote - blank rows. If you
actually meant blank cells, then mine will not give that.

--
Regards,
Tom Ogilvy

"Tom Ogilvy" wrote in message
...
If the rng contains either blanks or constant values
Sub CountBlankRows()
Dim rng As Range, rng1 As Range, rng2 As Range
Set rng = Range("A1:Z100")
Set rng1 = Intersect(rng, ActiveSheet.UsedRange)
If Not rng1 Is Nothing Then
NonUsedRows = rng.Rows.Count - rng1.Rows.Count
On Error Resume Next
Set rng2 = rng1.SpecialCells(xlConstants).EntireRow
On Error GoTo 0
If rng2 Is Nothing Then
nrow = 0
Else
nrow = Intersect(rng2, Columns(1)).Count
End If
MsgBox NonUsedRows + _
(rng1.Rows.Count - nrow)
Else
MsgBox rng.Rows.Count
End If

End Sub

--
Regards,
Tom Ogilvy


"Sanka" wrote in message
...
How to get the number of Blanks rows in a range in VBA







Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Range naming cells with blank cells through coding Naveen J V Excel Discussion (Misc queries) 1 March 27th 08 01:46 PM
If certain cells not blank, and cells in range are, set values to ktoth04 Excel Discussion (Misc queries) 0 February 21st 08 09:01 PM
Maximum Number of Blank Cells between Non Blank Cells in a Range Mal Excel Worksheet Functions 5 November 3rd 07 08:21 AM
Range object without blank cells RMJames Excel Discussion (Misc queries) 1 January 24th 06 02:15 PM
How do I skip blank cells when copying over a range of cells? tawells Excel Discussion (Misc queries) 2 June 7th 05 09:36 PM


All times are GMT +1. The time now is 01:32 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"