Msg Box with Rich Text

Pestomania

Active Member
Joined
May 30, 2018
Messages
292
Office Version
  1. 365
Platform
  1. Windows
I am unsure of how to explain this but I will do my best!

I currently utilize a module that can count and sum based on the color of a cell or the font. It works wonders
HTML:
https://www.ablebits.com/office-addins-blog/2013/12/12/count-sum-by-color-excel/comment-page-2/
.

Whenever that information is "summed" up on my excel sheet, I want to be able to have a pop-up that when the cell is selected, the msgbox will show all of the parts that were of the same color.

Here is my thoughts:

PartQtyPriceTotal
Apple4$5$20
Pear7$1$7
Banana20$0.50$10
Orange5$1$5
Sum of "Red"$25

<tbody>
</tbody>


Let's say the "Total" Column is highlighted "red" for "Apple" and "Banana".

Whenever the cell that has $25 in it is selected a pop-up msgbox would have the information such as:

Data to get Sum:
4 Apples at $5 = $20
and
$20 bananas at $0.50 = $10


I hope this all makes sense.

Thank you for any help!
 

Excel Facts

Show numbers in thousands?
Use a custom number format of #,##0,K. Each comma after the final 0 will divide the displayed number by another thousand
Don't you expect in your example to have a sum of $30?

Why can't you use the SumCellsByFontColor function from that website?
 
Upvote 0
Please disregard the mistake with the math. It should be $30, not $25.
 
Upvote 0
I suspect you DID use that routine.

I don't know about a popup msgbox, but how about another macro?

Code:
Sub ApplyColors()
'   get cell colors from B14 to use to check the data values

    Dim FontColor As Long, BkGrndClr As Long, i As Integer

    With Range("B14")
        FontColor = .Font.Color
        BkGrndClr = .Interior.Color  ' set an interior color to what the data cells should contain.
    End With
'
'   apply colors to the cells
'
    For i = 7 To 12  ' the data was in C7 to C12 -- adjust as needed
      If FontColor = Range("C" & i).Font.Color Then
        Range("C" & i).Interior.Color = BkGrndClr
        Else
      End If
    Next i
End Sub
 
Last edited:
Upvote 0
You might want to add this code after the "End With" -- again, of course, changing your ranges accordingly.

Code:
' Clear data cell backgrounds (set to white)
   Range("C7:C12").Interior.ColorIndex = 2
 
Last edited:
Upvote 0
Alternatively, since the grid lines go away with the previous approach, you could do this:

Code:
' Clear data cell backgrounds (set to normal)
    Range("C7:C14").Select
    With Selection.Interior
        .Pattern = xlNone
        .TintAndShade = 0
        .PatternTintAndShade = 0
    End With
 
Upvote 0
I suspect you DID use that routine.

I don't know about a popup msgbox, but how about another macro?

Code:
Sub ApplyColors()
'   get cell colors from B14 to use to check the data values

    Dim FontColor As Long, BkGrndClr As Long, i As Integer

    With Range("B14")
        FontColor = .Font.Color
        BkGrndClr = .Interior.Color  ' set an interior color to what the data cells should contain.
    End With
'
'   apply colors to the cells
'
    For i = 7 To 12  ' the data was in C7 to C12 -- adjust as needed
      If FontColor = Range("C" & i).Font.Color Then
        Range("C" & i).Interior.Color = BkGrndClr
        Else
      End If
    Next i
End Sub

Hi. Thank you for your reply. I don't think understand your macro. The macros I am using work well for what they need to do. Im hoping to be able to select that "total" cell and if would pop up which rows gave me that total.

When I get home, I will try to make an example to post.
 
Upvote 0

Forum statistics

Threads
1,214,975
Messages
6,122,537
Members
449,088
Latest member
RandomExceller01

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