Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 05-17-2017, 12:30 PM
Kubi Kubi is offline add sum colour cell to a button Windows XP add sum colour cell to a button Office XP
Advanced Beginner
add sum colour cell to a button
 
Join Date: May 2017
Posts: 34
Kubi is on a distinguished road
Default add sum colour cell to a button

I can add a sum colour cell formula and i can add a button however i can not get them to work together.



or alternately can you enter a formula to colour a different cell based on whats entered across other cells.
for example (if sheet1A2 = data!A1:A10 then colour F2 red) is something like that possible??
Reply With Quote
  #2  
Old 05-17-2017, 01:21 PM
Logit Logit is offline add sum colour cell to a button Windows 10 add sum colour cell to a button Office 2007
Expert
 
Join Date: Jan 2017
Posts: 533
Logit is a jewel in the roughLogit is a jewel in the roughLogit is a jewel in the rough
Default

Need more info.
Reply With Quote
  #3  
Old 05-17-2017, 01:54 PM
Kubi Kubi is offline add sum colour cell to a button Windows XP add sum colour cell to a button Office XP
Advanced Beginner
add sum colour cell to a button
 
Join Date: May 2017
Posts: 34
Kubi is on a distinguished road
Default

I would like to have a button on the sheet assigned to sum a cell colour so someone can go through and colour the cells (lets say within rows B&C) and then hit the button to provide the total sum.

different button for each colour.

does that help?
Reply With Quote
  #4  
Old 05-17-2017, 02:21 PM
Logit Logit is offline add sum colour cell to a button Windows 10 add sum colour cell to a button Office 2007
Expert
 
Join Date: Jan 2017
Posts: 533
Logit is a jewel in the roughLogit is a jewel in the roughLogit is a jewel in the rough
Default

Paste this code in the Sheet Level Module:

Code:
Option Explicit

Sub cmdBtn1()
   Sheets("Sheet1").Range("A3").Value = "=ColorFunction(A3,B2:C100,TRUE)"
End Sub

Sub cmdBtn2()
   Sheets("Sheet1").Range("A7").Value = "=ColorFunction(A7,B2:C100,TRUE)"
End Sub
Paste this code into a Routine Module:

Code:
Option Explicit

Function ColorFunction(rColor As Range, rRange As Range, Optional SUM As Boolean)
Dim rCell As Range
Dim lCol As Long
Dim vResult
lCol = rColor.Interior.ColorIndex
    If SUM = True Then
        For Each rCell In rRange
                If rCell.Interior.ColorIndex = lCol Then
                    vResult = WorksheetFunction.SUM(rCell, vResult)
                End If
        Next rCell
            Else
                For Each rCell In rRange
                    If rCell.Interior.ColorIndex = lCol Then
                        vResult = 1 + vResult
                    End If
                Next rCell
    End If
ColorFunction = vResult
End Function

You can expand the colors and buttons by following the pattern in the code.
Attached Files
File Type: xlsm Sum By Color.xlsm (18.2 KB, 11 views)
Reply With Quote
  #5  
Old 05-17-2017, 02:37 PM
Kubi Kubi is offline add sum colour cell to a button Windows XP add sum colour cell to a button Office XP
Advanced Beginner
add sum colour cell to a button
 
Join Date: May 2017
Posts: 34
Kubi is on a distinguished road
Default

thank you for that, i will give it a try and let you know.
Reply With Quote
  #6  
Old 05-17-2017, 03:45 PM
Logit Logit is offline add sum colour cell to a button Windows 10 add sum colour cell to a button Office 2007
Expert
 
Join Date: Jan 2017
Posts: 533
Logit is a jewel in the roughLogit is a jewel in the roughLogit is a jewel in the rough
Default

You are welcome.
Reply With Quote
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
add sum colour cell to a button Colour code mail merge header table cell backgrounds ScotsMaverick Mail Merge 25 11-04-2021 02:07 PM
add sum colour cell to a button colour codeing a cell by entering data gazza uk Excel 6 05-29-2014 09:52 AM
VBA to immediately change the colour of a cell depending on the code placed in anothe Phil Payne Excel Programming 2 07-27-2013 11:04 PM
add sum colour cell to a button Quadrant colour based on cell value RoyLittle0 Excel 2 05-05-2013 12:50 AM
CHange colour of footer if a cell changes to red OTPM Excel 0 05-26-2011 07:15 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 01:29 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft