Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 181
Default countblank sintax

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:Q2 0,_
O23:Q23,J26,A30:Q35,A38:Q44,G17,N26:Q26,J23:K23,C4 6,_
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




  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,058
Default countblank sintax

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:Q2 0,_
O23:Q23,J26,A30:Q35,A38:Q44,G17,N26:Q26,J23:K23,C4 6,_
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




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,355
Default countblank sintax


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,C 46," & _
"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:Q2 0,_
O23:Q23,J26,A30:Q35,A38:Q44,G17,N26:Q26,J23:K23,C4 6,_
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
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
Countblank Pat Excel Worksheet Functions 1 December 8th 09 08:28 PM
countblank Alberto Ast[_2_] Excel Programming 2 September 13th 09 06:01 AM
array sintax Paulo Excel Programming 3 October 2nd 08 03:07 PM
COUNTBLANK function Latika Excel Worksheet Functions 2 July 10th 06 05:20 PM
COUNTBLANK function Ian P Excel Worksheet Functions 4 May 21st 06 06:49 PM


All times are GMT +1. The time now is 01:15 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"