count function, is that correct?

earp_

Active Member
Joined
Apr 30, 2008
Messages
305
i found also this
Quote:
<table border="0" cellpadding="6" cellspacing="0" width="100%"> <tbody><tr> <td class="alt2" style="border: 1px inset ;"> myNum = WorksheetFunction.Count(Range(pIndex & "1").EntireColumn) </td> </tr> </tbody></table>
the 1 means that it starts from the first row right?
instead if I want it to start from the row 2, i just need to put 2 or write
new = myNum - 1, right?
 

Excel Facts

Which Excel functions can ignore hidden rows?
The SUBTOTAL and AGGREGATE functions ignore hidden rows. AGGREGATE can also exclude error cells and more.
It's not clear what you are trying to do.

If pIndex stores "A", Range(pIndex & "1").EntireColumn will select column A. Or, more specifically, Range(pIndex & "1") will read Range("A1") then .EntireColumn selects the whole column of the selected range (A1). So, WorksheetFunction.Count(Range(pIndex & "1").EntireColumn) is equivalent to WorksheetFunction.Count(Range("A:A"))

If you change the "1" to a "2", it won't have an impact on the result, since you're working with .EntireColumn anyway.

new = myNum - 1 will subtract 1 from the returned count. It is different from putting a "2" in WorksheetFunction.Count(Range(pIndex & "1").EntireColumn).... though, putting a "2" or a "1" in the formula does not matter.
 
Upvote 0
pIndex is probably a letter value indicating column, such as "A". Thus,

pIndex = "A"

pIndex & "1" = "A1"

The .EntireColumn makes the reference entire column, such as "A:A" and returns the corresponding range object. This shouldn't matter, generally, since Count only looks at numeric values, and I'm assuming your first row is header?
 
Upvote 0
pIndex contains "A", right.
I just want to count the elements in A from the second row to the end.
In the first row there is a value that I don't want to consider for counting.
So I guess I can count all the column and then do '-1' for not considering the first row.
Or, if you have any suggests pls let me know.
 
Upvote 0

Forum statistics

Threads
1,214,821
Messages
6,121,762
Members
449,048
Latest member
excelknuckles

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