#1   Report Post  
simonkf
 
Posts: n/a
Default counting


I need to create a formula/macro that will scroll down a column,
counting the number of instances of data. I think this is better
explained by the example below

1
1.1
1.2
1.3

2
2.1
2.2
2.3
2.4
2.5
I need to count the number of whole numbers and also the number of
decimals under each one. Each set of numbers is variable in length, 1
may have 3 steps and another 100s.

If any one can help that'd be much appreciated.
Thanks
Simon


--
simonkf
------------------------------------------------------------------------
simonkf's Profile: http://www.excelforum.com/member.php...o&userid=15821
View this thread: http://www.excelforum.com/showthread...hreadid=273137

  #2   Report Post  
schuurke28
 
Posts: n/a
Default


something like this?


Sub testje()
Dim i As Long, value As Variant, decimals As Long, wholenumbers As
Integer
For i = 1 To ActiveSheet.UsedRange.Rows.Count
value = Cells(i, 1).value
If IsNumeric(value) And Not IsEmpty(value) Then
'point or comma for numbers are depending of pc
settings
If InStr(1, value, ",") + InStr(1, value, ",") 0
Then
decimals = decimals + 1
Else
wholenumbers = wholenumbers + 1
End If
End If
Next i

MsgBox "# decimals : " & decimals & vbCrLf & "# wholenumbers : " &
wholenumbers

End Sub


--
schuurke28
------------------------------------------------------------------------
schuurke28's Profile: http://www.excelforum.com/member.php...o&userid=15818
View this thread: http://www.excelforum.com/showthread...hreadid=273137

  #3   Report Post  
schuurke28
 
Posts: n/a
Default


something like this?

Sub nrValues()
Dim i As Long, value As Variant, decimals As Long, wholenumbers As
Integer
For i = 1 To ActiveSheet.UsedRange.Rows.Count
value = Cells(i, 1).value
If IsNumeric(value) And Not IsEmpty(value) Then
'point or comma for numbers are depending of pc
settings
If InStr(1, value, ",") + InStr(1, value, ",") 0
Then
decimals = decimals + 1
Else
wholenumbers = wholenumbers + 1
End If
End If
Next i

MsgBox "# decimals : " & decimals & vbCrLf & "# wholenumbers : " &
wholenumbers

End Sub


--
schuurke28
------------------------------------------------------------------------
schuurke28's Profile: http://www.excelforum.com/member.php...o&userid=15818
View this thread: http://www.excelforum.com/showthread...hreadid=273137

  #4   Report Post  
Domenic
 
Posts: n/a
Default


Whole numbers...

=SUMPRODUCT(--(1-ISNUMBER(SEARCH(".",A1:A100))),--(A1:A100<""))

Number of decimals...

=SUMPRODUCT(--(ISNUMBER(SEARCH("1.",A1:A100))))

OR

=SUMPRODUCT(--(ISNUMBER(SEARCH(B1&".",A1:A100))))

...where B1 contains the number of interest.

Hope this helps!


--
Domenic
------------------------------------------------------------------------
Domenic's Profile: http://www.excelforum.com/member.php...o&userid=10785
View this thread: http://www.excelforum.com/showthread...hreadid=273137

  #5   Report Post  
LanceB
 
Posts: n/a
Default

=SUMPRODUCT((INT(A1:A11)0)*1) ' for the interger count
=SUMPRODUCT((A1:A11-INT(A1:A11)0)*1) 'for the fractional count



"simonkf" wrote:


I need to create a formula/macro that will scroll down a column,
counting the number of instances of data. I think this is better
explained by the example below

1
1.1
1.2
1.3

2
2.1
2.2
2.3
2.4
2.5
I need to count the number of whole numbers and also the number of
decimals under each one. Each set of numbers is variable in length, 1
may have 3 steps and another 100s.

If any one can help that'd be much appreciated.
Thanks
Simon


--
simonkf
------------------------------------------------------------------------
simonkf's Profile: http://www.excelforum.com/member.php...o&userid=15821
View this thread: http://www.excelforum.com/showthread...hreadid=273137




  #6   Report Post  
schuurke28
 
Posts: n/a
Default


last post is not correct!
=SUMPRODUCT((INT(A1:A11)0)*1) ' for the integer count

this will count all numbers as integers


--
schuurke28
------------------------------------------------------------------------
schuurke28's Profile: http://www.excelforum.com/member.php...o&userid=15818
View this thread: http://www.excelforum.com/showthread...hreadid=273137

  #7   Report Post  
Myrna Larson
 
Posts: n/a
Default

Your second formula works for me, but not the first.

Putting the 4 numbers 1, 1.1, 1.2, 1.3, into A1:A4, and writing the formula

=SUMPRODUCT((INT(A1:A4)0)*1)

gives a result of 4, not 1. You are, in effect, just counting the number of
cells containing numbers = 1.

You can get the correct result of 1 by using your 2nd formula but change 0 to
=0.

These formulas will also work:

to count integers: =SUMPRODUCT(--(INT(A1:A11)=A1:A11))
to count non-integers: =SUMPRODUCT(--(INT(A1:A11)<A1:A11))


On Thu, 28 Oct 2004 07:51:05 -0700, LanceB
wrote:

=SUMPRODUCT((INT(A1:A11)0)*1) ' for the interger count
=SUMPRODUCT((A1:A11-INT(A1:A11)0)*1) 'for the fractional count



"simonkf" wrote:


I need to create a formula/macro that will scroll down a column,
counting the number of instances of data. I think this is better
explained by the example below

1
1.1
1.2
1.3

2
2.1
2.2
2.3
2.4
2.5
I need to count the number of whole numbers and also the number of
decimals under each one. Each set of numbers is variable in length, 1
may have 3 steps and another 100s.

If any one can help that'd be much appreciated.
Thanks
Simon


--
simonkf
------------------------------------------------------------------------
simonkf's Profile:

http://www.excelforum.com/member.php...o&userid=15821
View this thread: http://www.excelforum.com/showthread...hreadid=273137



  #8   Report Post  
LanceB
 
Posts: n/a
Default

I misunderstood the question, I assumed he wanted all the numbers that
contained at least 1 whole number. Thanks for the correction.

Lance


"Myrna Larson" wrote:

Your second formula works for me, but not the first.

Putting the 4 numbers 1, 1.1, 1.2, 1.3, into A1:A4, and writing the formula

=SUMPRODUCT((INT(A1:A4)0)*1)

gives a result of 4, not 1. You are, in effect, just counting the number of
cells containing numbers = 1.

You can get the correct result of 1 by using your 2nd formula but change 0 to
=0.

These formulas will also work:

to count integers: =SUMPRODUCT(--(INT(A1:A11)=A1:A11))
to count non-integers: =SUMPRODUCT(--(INT(A1:A11)<A1:A11))


On Thu, 28 Oct 2004 07:51:05 -0700, LanceB
wrote:

=SUMPRODUCT((INT(A1:A11)0)*1) ' for the interger count
=SUMPRODUCT((A1:A11-INT(A1:A11)0)*1) 'for the fractional count



"simonkf" wrote:


I need to create a formula/macro that will scroll down a column,
counting the number of instances of data. I think this is better
explained by the example below

1
1.1
1.2
1.3

2
2.1
2.2
2.3
2.4
2.5
I need to count the number of whole numbers and also the number of
decimals under each one. Each set of numbers is variable in length, 1
may have 3 steps and another 100s.

If any one can help that'd be much appreciated.
Thanks
Simon


--
simonkf
------------------------------------------------------------------------
simonkf's Profile:

http://www.excelforum.com/member.php...o&userid=15821
View this thread: http://www.excelforum.com/showthread...hreadid=273137




Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Counting Rainfall Data TightIsobars Excel Discussion (Misc queries) 2 January 17th 05 11:45 PM
counting instances of words in a worksheet cell CJ Excel Discussion (Misc queries) 2 December 22nd 04 02:49 AM
Counting With Blank Rows SMDIYDLI Excel Discussion (Misc queries) 4 December 21st 04 09:00 AM
counting non occur entries excelFan Excel Discussion (Misc queries) 2 December 15th 04 07:15 PM
Counting instances in a cell [email protected] Excel Discussion (Misc queries) 2 December 11th 04 03:14 PM


All times are GMT +1. The time now is 07:39 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"