Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 30
Default CountIF = function not defined ???

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
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,494
Default CountIF = function not defined ???

try WorksheetFunction.CountIf

--


Gary


"John" wrote in message
...
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



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 30
Default CountIF = function not defined ???

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

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,494
Default CountIF = function not defined ???

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" wrote in message
...
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



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default CountIF = function not defined ???

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




  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 30
Default CountIF = function not defined ???

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.

  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 30
Default CountIF = function not defined ???

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
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
Using dcount function within user-defined worksheet function pongthai Excel Programming 3 January 15th 07 09:55 AM
Excel - User Defined Function Error: This function takes no argume BruceInCalgary Excel Programming 3 August 23rd 06 08:53 PM
Need to open the Function Arguments window from VBA for a user defined function. [email protected] Excel Programming 0 June 20th 06 03:53 PM
COUNTIF 2 Conditions using Defined Names Paul Dennis Excel Worksheet Functions 8 January 18th 06 07:21 AM
User-Defined Function pre-empting Built-in Function? How to undo???? MarWun Excel Programming 1 August 6th 03 09:31 PM


All times are GMT +1. The time now is 09:02 PM.

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

About Us

"It's about Microsoft Excel"