Countif giving me 0

tt.viquel

New Member
Joined
Apr 14, 2011
Messages
30
I have changed this countif formula into a macro: but it is giving me 0 instead of 10 does anyone know why??

Code:
=COUNTIF(KTPT80T!G:G,"Y")

Code:
Sub test()
Dim x As Long
x = Range("G" & Rows.Count).End(xlUp).Row
If x < 100 Then x = 100
Range("Z2") = Application.WorksheetFunction.CountIf(Range("G5:G" & x), "Y")
End Sub
 

Excel Facts

Links? Where??
If Excel says you have links but you can't find them, go to Formulas, Name Manager. Look for old links to dead workbooks & delete.
Hi,

really it worked for you, it is working but it is suppose to return the value of 10 as there are 10 Y's but it is giving me the result of 0. I am definately sure i referenced the cells correctly :confused:

Thanks
 
Upvote 0
Just a thought. I noticed you are starting at G5. Is that the correct starting cell? I did get 0 when my column/cell references were off. For example, I deleted some columns, but didn't update the code. Once I changed the code to the new columns the code worked again.
 
Upvote 0
]G5 is the column where the Y's start from, yes it's the correct cell. Do you think it could be this part :
Code:
If x < 100 Then x = 100
 
Upvote 0
in column G it goes up to G14 that is the last Y, but I want it to be dynamic as there will be continual amendments to it...deleting and adding more data
 
Upvote 0

Forum statistics

Threads
1,224,517
Messages
6,179,242
Members
452,898
Latest member
Capolavoro009

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top