Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 271
Default vba for countif

I have a table of data in range A1:F10. In cell H1 I have the following
array formula: =SUM((A2:A10=J1)*(B2:B10=K1)*(C2:C10=L1)*(D2:F10=M 1))

I don't want VBA that will put this formula into H1; rather, I want a VBA
that will make the Value of H1 equal to the result of a like VBA formula.



--
Thanks
Shawn
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 271
Default vba for countif

I seem to have figured it out:

Worksheets("Sheet1").Range("h2").Value = Evaluate("=SUMPRODUCT((A1:A10 =
J1)*(B1:B10=k1)*(C1:C10=L1)*(D1:F10=m1))")

--
Thanks
Shawn


"Shawn" wrote:

I have a table of data in range A1:F10. In cell H1 I have the following
array formula: =SUM((A2:A10=J1)*(B2:B10=K1)*(C2:C10=L1)*(D2:F10=M 1))

I don't want VBA that will put this formula into H1; rather, I want a VBA
that will make the Value of H1 equal to the result of a like VBA formula.



--
Thanks
Shawn

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,253
Default vba for countif


dont use global(application) evaluate if you want your code
to work consistently (and independant of activesheet)

instead use worksheets("sheet1").evaluate




--
keepITcool
| www.XLsupport.com | keepITcool chello nl | amsterdam


Shawn wrote :

I seem to have figured it out:

Worksheets("Sheet1").Range("h2").Value =
Evaluate("=SUMPRODUCT((A1:A10 =
J1)*(B1:B10=k1)*(C1:C10=L1)*(D1:F10=m1))")

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,120
Default vba for countif

Why did you switch to SUMPROUCT, SUM worked as well?

--
HTH

Bob Phillips

"Shawn" wrote in message
...
I seem to have figured it out:

Worksheets("Sheet1").Range("h2").Value = Evaluate("=SUMPRODUCT((A1:A10 =
J1)*(B1:B10=k1)*(C1:C10=L1)*(D1:F10=m1))")

--
Thanks
Shawn


"Shawn" wrote:

I have a table of data in range A1:F10. In cell H1 I have the following
array formula: =SUM((A2:A10=J1)*(B2:B10=K1)*(C2:C10=L1)*(D2:F10=M 1))

I don't want VBA that will put this formula into H1; rather, I want a

VBA
that will make the Value of H1 equal to the result of a like VBA

formula.



--
Thanks
Shawn



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
countif Ken Excel Discussion (Misc queries) 3 April 23rd 08 05:55 PM
How do I use a countif function according to two other countif fu. Kirsty Excel Worksheet Functions 2 February 20th 06 11:44 AM
edit this =COUNTIF(A1:F16,"*1-2*")+COUNTIF(A1:F16,"*2-1*") sctroy Excel Discussion (Misc queries) 2 September 25th 05 04:13 AM
COUNTIF or not to COUNTIF on a range in another sheet Ellie Excel Worksheet Functions 4 September 15th 05 10:06 PM
COUNTIF in one colum then COUNTIF in another...??? JonnieP Excel Worksheet Functions 3 February 22nd 05 02:55 PM


All times are GMT +1. The time now is 04:26 AM.

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"