View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.misc
Kevin B Kevin B is offline
external usenet poster
 
Posts: 1,316
Default Count Highlighted Rows

If you put the function in a worksheet module you will get the #Name error.

Press Alt+F11 to open the VBE and insert a new module by clicking INSERT in
the menu and selecting MODULE. Double click on the Sheet# icon under the
Microsoft Excel Objects folder in the VBA Project Explorer window, cut the
formula and paste it into the new module.

Add the following line under the Dim statement:

Application.Volatile

This will force the formula to recalc whenever the worksheet recalcs or you
press F9

--
Kevin Backmann


"Anonymous" wrote:

I created the function. However, when I put =countem() in a cell I get the
following error:

#NAME?

"Kevin B" wrote:

If you want the count displayed in a cell as result, you can use the
following custom function:

Function CountEm() As Long

Dim lngRows As Long

lngRows = Selection.Rows.Count

CountEm = lngRows

End Function

--
Kevin Backmann


"Marcelo" wrote:

Hi,

take a look at
http://www.cpearson.com/excel/SortByColor.htm

or if you just want to know how many numbers are in selected rows, right
click below the sheets guide and chose count

hth
--
regards from Brazil
Thanks in advance for your feedback.
Marcelo



"Anonymous" escreveu:

How do I count the number of highlighted rows?

Thanks!