Counting the number of Samples in Excel

dslt

New Member
Joined
Sep 13, 2011
Messages
12
Hello Everybody,

I need help where I used the code [to count the number of samples within a unknown range] and it worked:

Const COL_RESULTS = 2 ' all results in this column
Const ROW_RESULTS = 13 ' reference row
Const ROW_SAMPLES = ROW_RESULTS + 1 ' how many wind samples found

Sub Count_Selection()
Dim cell As Variant
Dim count As Integer
For Each cell In Selection
If cell > 0 Then
count = ROW_SAMPLES
End If
End Sub

However the Selection Part has to be an unknown range, inwhich when I use this code whichever workbook I use it can be implemented. I don't know how to add this unknown range into this code.

Also the count = ROW_SAMPLES is a function where i go onto excel and type:
= count(range)
it gives me the answer
But I'm not allowed to do that I have to let it run normally and let the answer end up in cell "I17"

Any Help will be appreciated :] thankyou!
 

Excel Facts

Show numbers in thousands?
Use a custom number format of #,##0,K. Each comma after the final 0 will divide the displayed number by another thousand

Forum statistics

Threads
1,224,522
Messages
6,179,292
Members
452,902
Latest member
Knuddeluff

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