Results 1 to 11 of 11

SumByColour displays #VALUE!

Threaded View

  1. #1
    Registered User
    Join Date
    12-05-2023
    Location
    North West, England
    MS-Off Ver
    Office 16
    Posts
    6

    SumByColour displays #VALUE!

    Hi,

    I was wondering if anyone could help please. I have a spreadsheet and I am trying to sum by colour based on the colour of the cells that is defined by conditional formatting. I am not even close to being an expert so have cobbled some VBA code together by research on google.

    I am so close when I look at the result in the insert function it gives me the number I am after but when displayed in the spreadsheet I am getting #VALUE! see images, all values are formatted as a number with no spaces etc.

    The VBA code used is as follows. Please help it is driving me crazy!!!! Thanks in advance

    Function SumByColor(SumRange As Range, SumColor As Range)
    Dim SumColorValue As Integer
    Dim TotalSum As Long
    SumColorValue = SumColor.DisplayFormat.Interior.ColorIndex
    Set rCell = SumRange
    For Each rCell In SumRange
    If rCell.DisplayFormat.Interior.ColorIndex = SumColorValue Then
    TotalSum = TotalSum + rCell.Value
    End If
    Next rCell
    SumByColor = TotalSum
    End Function
    Capture.JPG
    Capture2.JPG
    Last edited by AliGW; 12-06-2023 at 04:36 AM. Reason: Code tags added - please review the forum guidelines.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] d:hh:mm to displays over 31 days like [hh]:mm displays over 24 hours.
    By smit.etha in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 02-17-2015, 11:59 AM
  2. [SOLVED] If displays #REF then value
    By siroco79 in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 02-13-2014, 10:01 AM
  3. [SOLVED] MSG BOX displays twice
    By delaneybob in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 06-13-2012, 06:04 PM
  4. Replies: 2
    Last Post: 11-02-2011, 10:55 AM
  5. No value displays a zero
    By Rodeoclown in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 06-08-2010, 12:16 AM
  6. 12:00 displays as 00:05 in XML
    By JanieA in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 03-25-2009, 11:12 PM
  7. [SOLVED] CSV c/r l/f displays as box
    By Al in forum Excel General
    Replies: 1
    Last Post: 05-17-2006, 08:50 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1