Count If Range?

H

Hazel

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.
 
M

Mike H

Hazel,

Try

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

Bob Phillips

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)
 
B

Bob Phillips

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 said:
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)
 
H

Hazel

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top