# More decimals??

#### excelis

##### New Member
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

Easy bullets in Excel
If you have a numeric keypad, press Alt+7 on numeric keypad to type a bullet in Excel.

#### Trevor G

##### Well-known Member
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], _``````

#### excelis

##### New Member
Yes it worked!!! Thank you very much for the fast reply!!!

#### Trevor G

##### Well-known Member
Pleaed to read you have a solution.

Replies
9
Views
35
Replies
8
Views
49
Replies
13
Views
136
Replies
11
Views
732
Replies
9
Views
57

1,109,434
Messages
5,528,742
Members
409,832
Latest member
Misspears10

### This Week's Hot Topics

• Change military grades into rank
Afternoon all Need help with formula that will change military rank (i.e. 1, 2, 3 into Amn, A1C, SrA). Running IF formula that does not work...
• VBA COUNTIF SOLUTION
Hi The following are the errors spread across the several columns from E to Q ie. 13 columns across several sheets with more than 500 rows per...
• INSERT ROW WITH SPECIFIS TEXT IN A COLUMN
Hi All! How can identify that that the row to be inserted has to be inserted before 1st row with specific text in column F. If I record the...
• Auto-Create a monthly Sign in sheet for preschool students
The image below is what each page looks like. Above is space for the "Child Name" "Month" "Class" School days are obviously Monday-Friday but...
• VBA vlookup multiple results
Hi folks, Hopefully someone out there can help. I have a list to vlookup which works (ish). the lookup only picks up the first instance of the...
• Extract values for earliest/latest times
I am trying to put together a formula to get the earliest start time, the latest end time from column A for each person in Column B-F without the...