MobileMobile | Continue

Excel Bar

Excel Bar

Your excel questions will be responsed by our excel experts within 24hrs.Our service is free.

 Forgot Pass?
 Register Now
Find
Hot Search: Vlookup Match VBA
View: 290|Reply: 5

Cell increment based on fill colour

[Copy link]

1

Topics

6

Posts

19

Integral

Member

Rank: 2

Integral
19
Post on 1-16-2017 09:13:40 | All posts |Read mode
Hi Guys,
Can anyone help with a problem I have. I need to increase a cell count by 1 or 0.5 based on the fill colour of the cell. I am using the following code to increment the count by 1, which works fine,  but i also need to increment the cell count by 0.5 if the cell is a different colour. I am using Excel 2010. Any help would be much appreciated.
Function Countcolour(rng As Range, colour As Range) As Long
Dim c As Range
Application.Volatile
For Each c In rng
    If c.Interior.ColorIndex = colour.Interior.ColorIndex Then
        Countcolour = Countcolour + 1
    End If
Next
End FunctionMany Thanks












Reply

Props Report

1

Topics

6

Posts

19

Integral

Member

Rank: 2

Integral
19
 Author| Post on 1-16-2017 10:17:42 | All posts



Hi and welcome to the forum. Unfortunately your post does not comply with Rule 3 of our Forum
RULES
. Use code tags around code.
Posting code between  CODE     /CODE  tags makes your code much easier to read and copy for testing, it also maintains VBA formatting.
Click on Edit to open your thread, then highlight your code and click the # icon at the top of your post window. More information about these and other tags can be found here
I'll change it for you on this occasion but note for the future.











Reply Support Opposition

Props Report

1

Topics

6

Posts

19

Integral

Member

Rank: 2

Integral
19
 Author| Post on 1-16-2017 11:07:22 | All posts



...put an Else clause in the IF block









Reply Support Opposition

Props Report

1

Topics

6

Posts

19

Integral

Member

Rank: 2

Integral
19
 Author| Post on 1-16-2017 11:59:26 | All posts



Thank you Richard

Reply Support Opposition

Props Report

1

Topics

6

Posts

19

Integral

Member

Rank: 2

Integral
19
 Author| Post on 1-17-2017 09:13:05 | All posts



Thank you Richard







Reply Support Opposition

Props Report

1

Topics

6

Posts

19

Integral

Member

Rank: 2

Integral
19
 Author| Post on 1-17-2017 09:47:05 | All posts



Hi Richard,
I am an excel novice so could you expand on your comment regarding the Else clause please.
Many Thanks
Reply Support Opposition

Props Report

Points policy of this forum

Archiver|Mobile|Small dark house|Contact us|Excel Bar

GMT-5, 11-18-2017 14:15 , Processed in 0.193359 second(s), 20 queries .

Powered by Discuz! X3

© 2001-2013 Comsenz Inc.

!fastreply! Top !return_list!