Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
txlonghorn1989
 
Posts: n/a
Default How to increase counter based on values in 2 different cells

I want to check 2 cells (2 different columns) for a worksheet.

Easy to do programmatically but not familiar with spreadsheet
functions. Here's what I want to do in psuedo code...

For every row (with data) in a worksheet
If column X cell = 1 AND column Y cell = 50
ctr = ctr + 1

Any help would be appreciated.

Mike

  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Bob Phillips
 
Posts: n/a
Default How to increase counter based on values in 2 different cells

Dim ctr As Long
Dim oRow As Range

For Each oRow In ActiveSheet.UsedRange.Rows
If Cells(oRow.Row, "X").Value = 1 And _
Cells(oRow.Row, "Y").Value = 50 Then
ctr = ctr + 1
End If
Next oRow


--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)

"txlonghorn1989" wrote in message
oups.com...
I want to check 2 cells (2 different columns) for a worksheet.

Easy to do programmatically but not familiar with spreadsheet
functions. Here's what I want to do in psuedo code...

For every row (with data) in a worksheet
If column X cell = 1 AND column Y cell = 50
ctr = ctr + 1

Any help would be appreciated.

Mike



  #3   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Ryan Poth
 
Posts: n/a
Default How to increase counter based on values in 2 different cells

Not sure if this is *precisely* what you need, but you could try this formula:

=SUM((X1:X65535=1)*(Y1:Y65535=50))

This must be array-entered (CTRL-SHIFT-ENTER)

Logically, I would think that this could be simplified to:

=SUM((X:X=1)*(Y:Y=50))

but I get #NUM! as a result when I do that. I'm not sure why.

HTH,
Ryan

"txlonghorn1989" wrote:

I want to check 2 cells (2 different columns) for a worksheet.

Easy to do programmatically but not familiar with spreadsheet
functions. Here's what I want to do in psuedo code...

For every row (with data) in a worksheet
If column X cell = 1 AND column Y cell = 50
ctr = ctr + 1

Any help would be appreciated.

Mike


  #4   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Bob Phillips
 
Posts: n/a
Default How to increase counter based on values in 2 different cells

because array formulae just don't work with complete columns.

--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)

"Ryan Poth" wrote in message
...
Not sure if this is *precisely* what you need, but you could try this

formula:

=SUM((X1:X65535=1)*(Y1:Y65535=50))

This must be array-entered (CTRL-SHIFT-ENTER)

Logically, I would think that this could be simplified to:

=SUM((X:X=1)*(Y:Y=50))

but I get #NUM! as a result when I do that. I'm not sure why.

HTH,
Ryan

"txlonghorn1989" wrote:

I want to check 2 cells (2 different columns) for a worksheet.

Easy to do programmatically but not familiar with spreadsheet
functions. Here's what I want to do in psuedo code...

For every row (with data) in a worksheet
If column X cell = 1 AND column Y cell = 50
ctr = ctr + 1

Any help would be appreciated.

Mike




  #5   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Ryan Poth
 
Posts: n/a
Default How to increase counter based on values in 2 different cells

Thanks Bob. I didn't know that (probably since I'd never tried it). Do you
think that could be classified as a bug, or can you think of any intended
reason for that? Just wondering.

Ryan

"Bob Phillips" wrote:

because array formulae just don't work with complete columns.

--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)

"Ryan Poth" wrote in message
...
Not sure if this is *precisely* what you need, but you could try this

formula:

=SUM((X1:X65535=1)*(Y1:Y65535=50))

This must be array-entered (CTRL-SHIFT-ENTER)

Logically, I would think that this could be simplified to:

=SUM((X:X=1)*(Y:Y=50))

but I get #NUM! as a result when I do that. I'm not sure why.

HTH,
Ryan

"txlonghorn1989" wrote:

I want to check 2 cells (2 different columns) for a worksheet.

Easy to do programmatically but not familiar with spreadsheet
functions. Here's what I want to do in psuedo code...

For every row (with data) in a worksheet
If column X cell = 1 AND column Y cell = 50
ctr = ctr + 1

Any help would be appreciated.

Mike







  #6   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Bob Phillips
 
Posts: n/a
Default How to increase counter based on values in 2 different cells

No I don't think it is a bug, I think it was a design decision when building
the early versions of Excel which have carried forward.

--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)

"Ryan Poth" wrote in message
...
Thanks Bob. I didn't know that (probably since I'd never tried it). Do you
think that could be classified as a bug, or can you think of any intended
reason for that? Just wondering.

Ryan

"Bob Phillips" wrote:

because array formulae just don't work with complete columns.

--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)

"Ryan Poth" wrote in message
...
Not sure if this is *precisely* what you need, but you could try this

formula:

=SUM((X1:X65535=1)*(Y1:Y65535=50))

This must be array-entered (CTRL-SHIFT-ENTER)

Logically, I would think that this could be simplified to:

=SUM((X:X=1)*(Y:Y=50))

but I get #NUM! as a result when I do that. I'm not sure why.

HTH,
Ryan

"txlonghorn1989" wrote:

I want to check 2 cells (2 different columns) for a worksheet.

Easy to do programmatically but not familiar with spreadsheet
functions. Here's what I want to do in psuedo code...

For every row (with data) in a worksheet
If column X cell = 1 AND column Y cell = 50
ctr = ctr + 1

Any help would be appreciated.

Mike







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
how do i add in numbers automatically based on adjacent cells cont lemskibar Excel Discussion (Misc queries) 2 December 22nd 05 05:27 PM
Automatically filling in cells based on another cell's content Ginger Excel Worksheet Functions 5 September 2nd 05 09:17 AM
moving cells based certain value Rose Davis New Users to Excel 1 August 29th 05 09:53 PM
locking cells based on results at runtime aken Excel Worksheet Functions 3 June 22nd 05 02:01 PM
paste special | values should work with merged cells PastingSpecial Excel Discussion (Misc queries) 1 June 20th 05 06:51 PM


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