PC Review


Reply
Thread Tools Rate Thread

countblank sintax

 
 
Alberto Ast
Guest
Posts: n/a
 
      24th Oct 2009
I am trying to count blanks on a large range of cells but I am getting an error

My function is as follows

If WorksheetFunction.CountBlank(Range_
("M5:Q5,J8,O8:Q8,O12:Q12,O14:Q14,O17:Q17,O20:Q20,_
O23:Q23,J26,A30:Q35,A38:Q44,G17,N26:Q26,J23:K23,C46,_
C48,C61,O61:Q61")) > 0 Then

when ever us a set as M5:Q5... those are merged cells... I tried with just
first cell of each merge cell lime just M5 but get same error

Run-time error '1004:
Unsable to get the CountBlank property of the worksheetFunction class




 
Reply With Quote
 
 
 
 
Gary''s Student
Guest
Posts: n/a
 
      25th Oct 2009
The range shoudl be contiguous:

Sub dural()
Set r = Range("A1:A3")
MsgBox (Application.WorksheetFunction.CountBlank(r))
Set r = Range("A1,A3")
MsgBox (Application.WorksheetFunction.CountBlank(r))
End Sub


The first countblank works, the second fails.
--
Gary''s Student - gsnu200908


"Alberto Ast" wrote:

> I am trying to count blanks on a large range of cells but I am getting an error
>
> My function is as follows
>
> If WorksheetFunction.CountBlank(Range_
> ("M5:Q5,J8,O8:Q8,O12:Q12,O14:Q14,O17:Q17,O20:Q20,_
> O23:Q23,J26,A30:Q35,A38:Q44,G17,N26:Q26,J23:K23,C46,_
> C48,C61,O61:Q61")) > 0 Then
>
> when ever us a set as M5:Q5... those are merged cells... I tried with just
> first cell of each merge cell lime just M5 but get same error
>
> Run-time error '1004:
> Unsable to get the CountBlank property of the worksheetFunction class
>
>
>
>

 
Reply With Quote
 
Barb Reinhardt
Guest
Posts: n/a
 
      25th Oct 2009

You could do something like this


Sub CountAllEmpty()
Dim myRange As Excel.Range
Dim myCount As Long
Dim r As Excel.Range


Set myRange = _
Range("M5:Q5,J8,O8:Q8,O12:Q12,O14:Q14,O17:Q17,O20:Q20," & _
"O23:Q23,J26,A30:Q35,A38:Q44,G17,N26:Q26,J23:K23,C46," & _
"C48 ,C61, O61:Q61")



myCount = 0
For Each r In myRange
If IsEmpty(r) Then
myCount = myCount + 1
End If
Next r
Debug.Print myCount, myRange.Count

End Sub

Maybe make it a function.

HTH,
Barb Reinhardt
"Alberto Ast" wrote:

> I am trying to count blanks on a large range of cells but I am getting an error
>
> My function is as follows
>
> If WorksheetFunction.CountBlank(Range_
> ("M5:Q5,J8,O8:Q8,O12:Q12,O14:Q14,O17:Q17,O20:Q20,_
> O23:Q23,J26,A30:Q35,A38:Q44,G17,N26:Q26,J23:K23,C46,_
> C48,C61,O61:Q61")) > 0 Then
>
> when ever us a set as M5:Q5... those are merged cells... I tried with just
> first cell of each merge cell lime just M5 but get same error
>
> Run-time error '1004:
> Unsable to get the CountBlank property of the worksheetFunction class
>
>
>
>

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
sintax explaination josh Microsoft ASP .NET 0 28th Aug 2008 12:18 PM
GoToRecord Sintax =?Utf-8?B?UmF1bCBTb3VzYQ==?= Microsoft Access Form Coding 6 29th Jan 2007 04:10 PM
#error sintax when trying to add sum+iif thread Microsoft Access Forms 3 30th Jun 2006 06:43 AM
Sintax error simon Microsoft ASP .NET 1 21st Sep 2005 11:12 AM
Sintax Help! Smonczka Microsoft Excel Discussion 4 24th May 2005 08:28 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 04:39 PM.