ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Macro and Count function (https://www.excelbanter.com/excel-programming/363478-macro-count-function.html)

Melissa

Macro and Count function
 
I am recording a macro in Excel 2003 (do not know or use VBA Editor) that
involves many different tasks in the worksheet. When I run the macro, it
runs everything except the CountIF function I recorded. I am using the
function to capture the number of times certain text appears in a column.
Any assistance on getting the macro to record the function?

Thanks.

Bob Phillips

Macro and Count function
 
Do you want the formula inserted

Activecell.Formula = "=COUNTIF(A1,A20,""some value"")"

or get the result

Msgbox Application.Countif(Range("A1:A20"),"some value")

--
HTH

Bob Phillips

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

"Melissa" wrote in message
...
I am recording a macro in Excel 2003 (do not know or use VBA Editor) that
involves many different tasks in the worksheet. When I run the macro, it
runs everything except the CountIF function I recorded. I am using the
function to capture the number of times certain text appears in a column.
Any assistance on getting the macro to record the function?

Thanks.




Gary''s Student

Macro and Count function
 
n = Application.CountIf(Range("A:A"), Range("B1"))



In VBA COUNTIF() needs to be spoon-fed the range.
--
Gary's Student


"Melissa" wrote:

I am recording a macro in Excel 2003 (do not know or use VBA Editor) that
involves many different tasks in the worksheet. When I run the macro, it
runs everything except the CountIF function I recorded. I am using the
function to capture the number of times certain text appears in a column.
Any assistance on getting the macro to record the function?

Thanks.



All times are GMT +1. The time now is 01:02 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com