More decimals??

excelis

New Member
Joined
Jun 3, 2010
Messages
38
Dear all,

I have come across this macro but the result that is giving is a number without decimals, even if the values of the cells have more decimals like 13,26 for example.

Do you know how and where should i write that i want the result with more decimals, for example instead of 100 to be 100,2435 ??

Thank you for your help!!


Code:
Sub SumColorCount()
 Dim Blue5 As Integer, _
 Red3 As Integer, _
 Yellow6 As Integer
 Dim Data As Range
 Dim Cell As Range

 Set Data = Range("A1:A1000")
 For Each Cell In Range("Data")
 If Cell.Interior.ColorIndex = 5 Then
 Blue5 = Blue5 + Cell.Value
 ElseIf Cell.Interior.ColorIndex = 3 Then
 Red3 = Red3 + Cell.Value
 ElseIf Cell.Interior.ColorIndex = 6 Then
 Yellow6 = Yellow6 + Cell.Value
 End If
 Next

 Range("F10").Value = "Blue = " & Blue5
 Range("F11").Value = "Red = " & Red3
 Range("F12").Value = "Yellow = " & Yellow6

 MsgBox "     You have: " & vbCr _
 & vbCr & "   Blue  " & Blue5 _
 & vbCr & "      Red     " & Red3 _
 & vbCr & "    Yellow   " & Yellow6, _
 vbOKOnly, "CountColor"

 Range("F10:F12").Value = ""

</pre>
 
Last edited:

Excel Facts

Copy a format multiple times
Select a formatted range. Double-click the Format Painter (left side of Home tab). You can paste formatting multiple times. Esc to stop
When you are using Integer this basically means whole numbers if you change this to Double this will give you decimal points.

So look to change the following (I haven't tested this).

Code:
Dim Blue5 As Integer, _
 Red3 As Integer, _

To
Code:
Dim Blue5 As [COLOR=royalblue]Double[/COLOR], _
 Red3 As [COLOR=royalblue]Double[/COLOR], _
 
Upvote 0

Forum statistics

Threads
1,224,603
Messages
6,179,849
Members
452,948
Latest member
UsmanAli786

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