Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
MDW MDW is offline
external usenet poster
 
Posts: 117
Default Use An Excel Built-In Function Entirely Within VBA

I'm not sure if this is possible or not, but I thought I'd give it a whirl.

If I have variables called SOME_ADDRSS, START_CELL and END_CELL (all strings
which contain valid cell addresses), I could use code to do something like
this:

Range(SOME_ADDRESS).Formula = "=COUNTIF(" & START_CELL & ":" & END_CELL &
",""0"")"
intResult = Range(SOME_ADDRESS).Value
Range(SOME_ADDRESS).Clear

intResult has the value I'm looking for. However, I need to write to a
certain range in the sheet in order to get it. I'd prefer to not do that, for
several obvious reasons. I don't want to have to check whether SOME_ADDRESS
is being used for actual value, etc. However, COUNTIF accomplishes exactly
what I want, and call me lazy but I don't want to reinvent the wheel if I
don't have to.

Is there a way I can get use of the COUNTIF functionality strictly within
VBA, and not just write my own version of it?

--
Hmm...they have the Internet on COMPUTERS now!
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,651
Default Use An Excel Built-In Function Entirely Within VBA

On Thu, 23 Feb 2006 09:11:28 -0800, MDW wrote:

I'm not sure if this is possible or not, but I thought I'd give it a whirl.

If I have variables called SOME_ADDRSS, START_CELL and END_CELL (all strings
which contain valid cell addresses), I could use code to do something like
this:

Range(SOME_ADDRESS).Formula = "=COUNTIF(" & START_CELL & ":" & END_CELL &
",""0"")"
intResult = Range(SOME_ADDRESS).Value
Range(SOME_ADDRESS).Clear

intResult has the value I'm looking for. However, I need to write to a
certain range in the sheet in order to get it. I'd prefer to not do that, for
several obvious reasons. I don't want to have to check whether SOME_ADDRESS
is being used for actual value, etc. However, COUNTIF accomplishes exactly
what I want, and call me lazy but I don't want to reinvent the wheel if I
don't have to.

Is there a way I can get use of the COUNTIF functionality strictly within
VBA, and not just write my own version of it?


intResult = Application.WorksheetFunction.CountIf _
(Range(START_CELL, END_CELL), "0")


--ron
  #3   Report Post  
Posted to microsoft.public.excel.programming
MDW MDW is offline
external usenet poster
 
Posts: 117
Default Use An Excel Built-In Function Entirely Within VBA

Wow....I don't think, in the history of my use on these boards, I've ever had
a reply to so EXACTLY gave me what I wanted.

You're my new hero.

--
Hmm...they have the Internet on COMPUTERS now!


"Ron Rosenfeld" wrote:

On Thu, 23 Feb 2006 09:11:28 -0800, MDW wrote:

I'm not sure if this is possible or not, but I thought I'd give it a whirl.

If I have variables called SOME_ADDRSS, START_CELL and END_CELL (all strings
which contain valid cell addresses), I could use code to do something like
this:

Range(SOME_ADDRESS).Formula = "=COUNTIF(" & START_CELL & ":" & END_CELL &
",""0"")"
intResult = Range(SOME_ADDRESS).Value
Range(SOME_ADDRESS).Clear

intResult has the value I'm looking for. However, I need to write to a
certain range in the sheet in order to get it. I'd prefer to not do that, for
several obvious reasons. I don't want to have to check whether SOME_ADDRESS
is being used for actual value, etc. However, COUNTIF accomplishes exactly
what I want, and call me lazy but I don't want to reinvent the wheel if I
don't have to.

Is there a way I can get use of the COUNTIF functionality strictly within
VBA, and not just write my own version of it?


intResult = Application.WorksheetFunction.CountIf _
(Range(START_CELL, END_CELL), "0")


--ron

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,651
Default Use An Excel Built-In Function Entirely Within VBA

On Thu, 23 Feb 2006 11:41:17 -0800, MDW wrote:

Wow....I don't think, in the history of my use on these boards, I've ever had
a reply to so EXACTLY gave me what I wanted.


That's related in no small part to your explaining EXACTLY what you wanted!


You're my new hero.


<blush


--ron
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
Sqr built-in function in Excel 2003 VBA DaleB Excel Discussion (Misc queries) 4 October 22nd 07 05:15 PM
built-in function doesn't work properly Calaozao Excel Programming 2 April 11th 05 06:10 PM
How can I build a Excel Function that acts like those built-in wlh Excel Programming 1 November 27th 03 08:18 AM
Access Recordset with Built-In Function Jeff Huff Excel Programming 3 November 10th 03 10:08 PM
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 11:17 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"