PC Review


Reply
Thread Tools Rate Thread

Count If Range?

 
 
=?Utf-8?B?SGF6ZWw=?=
Guest
Posts: n/a
 
      3rd Aug 2007
Hi All

Having a hard time with the following

Private Sub Add1_Click()
Dim iRow As Long
Dim ws As Worksheet
Set ws = Worksheets("Customers")
Worksheets("Customers").Select

Tb1.Value = Application.CountIf(Range("J3:J600"), "35") <<<< Working ok

What I need is

Tb1.Value = Application.CountIf(Range("J3:J600") ' ws("Prices") Range ("A2")
so that if I change the price from "35" to 40 in ("A2")("Prices") it will
count the "40" in the "Customers" sheet.

Is this possible please - over 2 hours down the line and still no further
forward.
--
Many thanks

hazel
 
Reply With Quote
 
 
 
 
=?Utf-8?B?TWlrZSBI?=
Guest
Posts: n/a
 
      3rd Aug 2007
Hazel,

Try

Tb1 = Application.WorksheetFunction.CountIf(Range("J1:J100"),
Sheets("Prices").Range("A1").Value)

"Hazel" wrote:

> Hi All
>
> Having a hard time with the following
>
> Private Sub Add1_Click()
> Dim iRow As Long
> Dim ws As Worksheet
> Set ws = Worksheets("Customers")
> Worksheets("Customers").Select
>
> Tb1.Value = Application.CountIf(Range("J3:J600"), "35") <<<< Working ok
>
> What I need is
>
> Tb1.Value = Application.CountIf(Range("J3:J600") ' ws("Prices") Range ("A2")
> so that if I change the price from "35" to 40 in ("A2")("Prices") it will
> count the "40" in the "Customers" sheet.
>
> Is this possible please - over 2 hours down the line and still no further
> forward.
> --
> Many thanks
>
> hazel

 
Reply With Quote
 
Bob Phillips
Guest
Posts: n/a
 
      3rd Aug 2007
Tb1.Value = Application.CountIf(Range("J3:J600"),ws("Prices").Range ("A2")
..Value)

--
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)

"Hazel" <(E-Mail Removed)> wrote in message
news:0CCB4194-CB53-4D4E-97BF-(E-Mail Removed)...
> Hi All
>
> Having a hard time with the following
>
> Private Sub Add1_Click()
> Dim iRow As Long
> Dim ws As Worksheet
> Set ws = Worksheets("Customers")
> Worksheets("Customers").Select
>
> Tb1.Value = Application.CountIf(Range("J3:J600"), "35") <<<< Working ok
>
> What I need is
>
> Tb1.Value = Application.CountIf(Range("J3:J600") ' ws("Prices") Range
> ("A2")
> so that if I change the price from "35" to 40 in ("A2")("Prices") it will
> count the "40" in the "Customers" sheet.
>
> Is this possible please - over 2 hours down the line and still no further
> forward.
> --
> Many thanks
>
> hazel



 
Reply With Quote
 
Bob Phillips
Guest
Posts: n/a
 
      3rd Aug 2007
typo

Tb1.Value = Application.CountIf(Range("J3:J600"),Worksheets("Prices").Range
("A2") .Value)


--
---
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)



"Bob Phillips" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Tb1.Value = Application.CountIf(Range("J3:J600"),ws("Prices").Range ("A2")
> .Value)
>
> --
> HTH
>
> Bob
>
> (there's no email, no snail mail, but somewhere should be gmail in my
> addy)
>
> "Hazel" <(E-Mail Removed)> wrote in message
> news:0CCB4194-CB53-4D4E-97BF-(E-Mail Removed)...
>> Hi All
>>
>> Having a hard time with the following
>>
>> Private Sub Add1_Click()
>> Dim iRow As Long
>> Dim ws As Worksheet
>> Set ws = Worksheets("Customers")
>> Worksheets("Customers").Select
>>
>> Tb1.Value = Application.CountIf(Range("J3:J600"), "35") <<<< Working ok
>>
>> What I need is
>>
>> Tb1.Value = Application.CountIf(Range("J3:J600") ' ws("Prices") Range
>> ("A2")
>> so that if I change the price from "35" to 40 in ("A2")("Prices") it will
>> count the "40" in the "Customers" sheet.
>>
>> Is this possible please - over 2 hours down the line and still no further
>> forward.
>> --
>> Many thanks
>>
>> hazel

>
>



 
Reply With Quote
 
=?Utf-8?B?SGF6ZWw=?=
Guest
Posts: n/a
 
      3rd Aug 2007
Hi Mike & Bob

As usual, I come back from Lunch and my problems are solved -- thanks to you
both. Going to try and get the label now to read the Prices ("A2") and then
the jobs done
--
Many thanks

hazel


"Mike H" wrote:

> Hazel,
>
> Try
>
> Tb1 = Application.WorksheetFunction.CountIf(Range("J1:J100"),
> Sheets("Prices").Range("A1").Value)
>
> "Hazel" wrote:
>
> > Hi All
> >
> > Having a hard time with the following
> >
> > Private Sub Add1_Click()
> > Dim iRow As Long
> > Dim ws As Worksheet
> > Set ws = Worksheets("Customers")
> > Worksheets("Customers").Select
> >
> > Tb1.Value = Application.CountIf(Range("J3:J600"), "35") <<<< Working ok
> >
> > What I need is
> >
> > Tb1.Value = Application.CountIf(Range("J3:J600") ' ws("Prices") Range ("A2")
> > so that if I change the price from "35" to 40 in ("A2")("Prices") it will
> > count the "40" in the "Customers" sheet.
> >
> > Is this possible please - over 2 hours down the line and still no further
> > forward.
> > --
> > Many thanks
> >
> > hazel

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Count Vaules in a range that appear in another range T Newbery Microsoft Excel Worksheet Functions 5 11th Feb 2010 05:08 PM
Multiple Criteria, Count If, Sum Product to get count across range Jonathan Microsoft Excel Worksheet Functions 5 9th Jan 2008 11:32 PM
How do Count a the number of times a date range appears within a date range!? leelondon Microsoft Excel Discussion 5 4th Oct 2006 12:12 PM
How to count dates within a certain range in a column with mutiple date range entries Krisjhn Microsoft Excel Worksheet Functions 2 1st Sep 2005 01:59 PM
Count cells in one range based on parameters in another range =?Utf-8?B?ZGF2ZSByb3Ro?= Microsoft Excel Worksheet Functions 2 29th Mar 2005 05:33 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 06:16 AM.