PDA

View Full Version : Count number of times word occurs in selected column?



clhare
03-18-2008, 07:55 AM
I need a macro to find out how many times specific text is found in a particular column of a spreadsheet. How would I do that?

Bob Phillips
03-18-2008, 07:59 AM
=COUNTIF(A:A,"the words")

clhare
03-18-2008, 08:05 AM
I pasted that code in the macro but it turns red. How do you use this code in a macro? Sorry--I'm very new to Excel VBA.

Bob Phillips
03-18-2008, 08:06 AM
It isn't macro code, it is a worksheet function. No need for a macro.

clhare
03-18-2008, 08:30 AM
Ok, I tried that and noticed that it changes my text in the first row to the function's text (so it gets counted there too). Why is that? Am I doing something wrong or do I just subtract 1 from the total found?

Bob Phillips
03-18-2008, 09:17 AM
I don't understand what you mean.

clhare
03-18-2008, 09:46 AM
I'm just not too good with Excel. I'll look up how to use functions in the book and figure out what I'm doing wrong.

Simon Lloyd
03-18-2008, 09:55 AM
If you dont want it to count A1 then why not =CountIf(A2:A65536, "the words")