PC Review


Reply
Thread Tools Rate Thread

CountIF = function not defined ???

 
 
John
Guest
Posts: n/a
 
      13th Jul 2007
excel vba 6.3 countif gets me a "Function not defined" error. I took the
example straight out of a book. MsgBox = CountIf(Col(1), "*") where
Col(1) is a range array.

I copied some more examples having nothing to do with my program into a
simple macro they all get the same error. Doesn't 6.3 (Excell 2003) have
Countif in it?

John
 
Reply With Quote
 
 
 
 
Gary Keramidas
Guest
Posts: n/a
 
      13th Jul 2007
try WorksheetFunction.CountIf

--


Gary


"John" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> excel vba 6.3 countif gets me a "Function not defined" error. I took the
> example straight out of a book. MsgBox = CountIf(Col(1), "*") where Col(1) is
> a range array.
>
> I copied some more examples having nothing to do with my program into a simple
> macro they all get the same error. Doesn't 6.3 (Excell 2003) have Countif in
> it?
>
> John



 
Reply With Quote
 
John
Guest
Posts: n/a
 
      13th Jul 2007
thanks... that did it.

Have another problem now. The countif doesn't work with a range I put
together using "union" I took a chance on that.

----
Dim Rows(9) as Range
Set Rows(n) = Union(Cells(n, 1), Cells(n, 3), Cells(n, 5))
----

I'm trying to have a collection or range or array of evey other cell in
a row that i can work with. Is that possible as a range? I tried to read
about collections but just got screwed up.

thanks

John

Gary Keramidas wrote:
> try WorksheetFunction.CountIf
>

 
Reply With Quote
 
Gary Keramidas
Guest
Posts: n/a
 
      13th Jul 2007
not exactly sure what you're trying to accomplish, but:

Option Base 1
Sub test()
Dim arr() As String
Dim i As Long, n As Long

For i = 1 To 18
If i Mod 2 = 1 Then
n = n + 1
ReDim Preserve arr(1 To n)
arr(n) = Cells(1, i).Value
End If
Next

End Sub

--


Gary


"John" <(E-Mail Removed)> wrote in message
news:%(E-Mail Removed)...
> thanks... that did it.
>
> Have another problem now. The countif doesn't work with a range I put together
> using "union" I took a chance on that.
>
> ----
> Dim Rows(9) as Range
> Set Rows(n) = Union(Cells(n, 1), Cells(n, 3), Cells(n, 5))
> ----
>
> I'm trying to have a collection or range or array of evey other cell in a row
> that i can work with. Is that possible as a range? I tried to read about
> collections but just got screwed up.
>
> thanks
>
> John
>
> Gary Keramidas wrote:
>> try WorksheetFunction.CountIf
>>



 
Reply With Quote
 
=?Utf-8?B?VG9tIE9naWx2eQ==?=
Guest
Posts: n/a
 
      13th Jul 2007
Countif works that same as it does in a worksheet. In a worksheet it would
not work with a discontiguous range either.

--
Regards,
Tom Ogilvy


"John" wrote:

> thanks... that did it.
>
> Have another problem now. The countif doesn't work with a range I put
> together using "union" I took a chance on that.
>
> ----
> Dim Rows(9) as Range
> Set Rows(n) = Union(Cells(n, 1), Cells(n, 3), Cells(n, 5))
> ----
>
> I'm trying to have a collection or range or array of evey other cell in
> a row that i can work with. Is that possible as a range? I tried to read
> about collections but just got screwed up.
>
> thanks
>
> John
>
> Gary Keramidas wrote:
> > try WorksheetFunction.CountIf
> >

>

 
Reply With Quote
 
John
Guest
Posts: n/a
 
      13th Jul 2007
Rats. So for non-contiguous you are back to for-next loop searches loops
instead of built in functions.
John

Tom Ogilvy wrote:

> Countif works that same as it does in a worksheet. In a worksheet it would
> not work with a discontiguous range either.
>

 
Reply With Quote
 
John
Guest
Posts: n/a
 
      13th Jul 2007
I Already do that... I was trying to find a neater way.

John

Gary Keramidas wrote:

> not exactly sure what you're trying to accomplish, but:
>
> Option Base 1
> Sub test()
> Dim arr() As String
> Dim i As Long, n As Long
>
> For i = 1 To 18
> If i Mod 2 = 1 Then
> n = n + 1
> ReDim Preserve arr(1 To n)
> arr(n) = Cells(1, i).Value
> End If
> Next
>
> End Sub
>

 
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
Excel - User Defined Function Error: This function takes no argume =?Utf-8?B?QnJ1Y2VJbkNhbGdhcnk=?= Microsoft Excel Programming 3 23rd Aug 2006 08:53 PM
COUNTIF 2 Conditions using Defined Names =?Utf-8?B?UGF1bCBEZW5uaXM=?= Microsoft Excel Worksheet Functions 8 18th Jan 2006 07:21 AM
COUNT /COUNTIF for Multiple Column Defined Dynamic Named Range Tinä Microsoft Excel Misc 0 26th Oct 2004 02:40 AM
COUNT /COUNTIF for Multiple Column Defined Dynamic Named Range Tinä Microsoft Excel Misc 1 26th Oct 2004 01:36 AM
User-Defined Function pre-empting Built-in Function? How to undo???? MarWun Microsoft Excel Programming 1 6th Aug 2003 09:31 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 12:00 PM.