Fill cells with color

heruxz

New member
Joined
Apr 18, 2024
Messages
1
Programming Experience
Beginner
I am currently working on a project in which I can send a table with information through a chime chat from excel, the problem is that I don't know how to fill the colored cells through the macro since I don't want it to be just gray and white.

This is the code I'm currently using and the table looks black and white only.

VB.NET:
Sub postACSWMissing()
    ' Actually ALGR
    ' Selection of Excel of Workbook to Post
    Dim table As String
    Dim dsp_a As String
    dsp_a = Worksheets("Info").Range("F4").Value
    ' Selection.End(xlToRight)
    
    Sheets("Pivots & Chime").Select
    Range("E5").Select
    
    With Worksheets("Pivots & Chime").Range(Selection, Selection.End(xlDown))
        
        For Each Row In .Rows
            table = table & Join(Array(Empty, Row.Cells(1, 1), Row.Cells(1, 2), Row.Cells(1, 3)), "|") & Chr(10)
            If Row.Row = .Row Then: table = table & "|-|-" & Chr(10)
        Next
        
    End With

    Call announce("/md " & Left(table, Len(table) - 1), dsp_a)
    
    ActiveWindow.ScrollColumn = 8
End Sub

Currently the table looks like this:

Untitled.png
 
Is this really VB.NET or is it actually VBA in Excel? It's not clear from the code but Call is completely unnecessary in VB.NET so it's use makes it look like an older VB flavour.
 
I believe what you are asking is something like this? I agree with jmcilhinney.
:
Sending Colored Cells from Excel to Chime Chat using VB.NET:
Private Sub SendColoredCellsToChimeChat()
    Dim chimeChat As Object
    Dim excelSheet As Worksheet
    Dim cell As Range
    Dim message As String
   
    ' Initialize Chime Chat API (Assuming you have a reference to the API)
    Set chimeChat = CreateObject("ChimeChatAPI.Client")
    Set excelSheet = ThisWorkbook.Sheets("Sheet1") ' Change to your sheet name

    message = ""

    ' Loop through each cell in the used range
    For Each cell In excelSheet.UsedRange
        If cell.Interior.Color <> RGB(255, 255, 255) Then ' Check if the cell is not white
            message = message & cell.Value & " (Color: " & cell.Interior.Color & ")" & vbCrLf
        End If
    Next cell

    ' Send the message to Chime Chat
    chimeChat.SendMessage "Your Chime Chat Room ID", message
End Sub
 
Back
Top