Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 26
Default Excel VBA Sumproduct

I've been working through what I think should be rather easy, but i'm
here asking ...

I have a very simple excel sheet that will have 5 to 50 rows or so
filled in, with 15 columns. What I want to do is count the unique
values in column C with vba code. Right now I'm using the following
formula: =sumproduct((C3:C35<"")/COUNTIF(C3:C35,C3:C35&""))") which
works well.

I'm trying to accomplish the same result with VBA. I've tried:

cntc = ("=sumproduct(countif(c3:c35,c3:c35))") which returns a count
of 47, but the count should be 29.

I've tried:cntc = Evaluate("=SUMPRODUCT((C3:C35<"")/
COUNTIF(C3:C35,C3:C35&""))"), which returns 0.

I have
DIm cntc as Range

Set cntc = Range("c65536").End(xlUp).Offset(2, 0)

then one of my two attempts above...

I feel like I'm very close, but what am I missing?

  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 5,441
Default Excel VBA Sumproduct

Gimp,

You need to double up internal double quote marks:

cntc = Evaluate("=SUMPRODUCT((C3:C35<"""")/COUNTIF(C3:C35,C3:C35&""""))")
MsgBox cntc

HTH,
Bernie
MS Excel MVP


"Gimp" wrote in message
oups.com...
I've been working through what I think should be rather easy, but i'm
here asking ...

I have a very simple excel sheet that will have 5 to 50 rows or so
filled in, with 15 columns. What I want to do is count the unique
values in column C with vba code. Right now I'm using the following
formula: =sumproduct((C3:C35<"")/COUNTIF(C3:C35,C3:C35&""))") which
works well.

I'm trying to accomplish the same result with VBA. I've tried:

cntc = ("=sumproduct(countif(c3:c35,c3:c35))") which returns a count
of 47, but the count should be 29.

I've tried:cntc = Evaluate("=SUMPRODUCT((C3:C35<"")/
COUNTIF(C3:C35,C3:C35&""))"), which returns 0.

I have
DIm cntc as Range

Set cntc = Range("c65536").End(xlUp).Offset(2, 0)

then one of my two attempts above...

I feel like I'm very close, but what am I missing?



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
Stop excel from dropping the 0 in the beginning of a number? Rosewood Setting up and Configuration of Excel 12 April 4th 23 02:12 PM
Excel : Nesting of functions such as sumproduct and sumif Nimish Shah Excel Worksheet Functions 6 December 22nd 06 01:27 PM
excel chart rendering problem when using apache java Poi package. Tom Excel Discussion (Misc queries) 0 December 21st 06 09:03 AM
Running Excel 2000 VBA Application on Excel 2003 Excel Worksheet Functions 0 August 8th 06 06:04 PM
Excel Range Value issue (Excel 97 Vs Excel 2003) Keeno Excel Discussion (Misc queries) 2 June 13th 05 02:01 PM


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