Quantcast
Channel: Excel Help Forum - Excel Programming / VBA / Macros
Viewing all articles
Browse latest Browse all 50067

Color formatting using VBA

$
0
0
IdealTasks.xlsm

Hello,
I'm trying to say --> If the cell color is blank Then say "I'm free". --> If the cell color is not blank Then say "I'm busy".

In the cell N4 for example, the cell at the end of the row, it needs to say either "I'm free" or "I'm busy." My range is from B4 to L484.

For example for the first row, B4 to L4, there is a red slot, so in N4 it needs to say "I'm busy" in the cell.

Code:

Public Sub CommandButton1_Click()

    Dim rng As Range
    Dim Index As Long
    Set rng = Selection
    Dim cell_selected As Object
   
cell_selected = Range("B4").Select
   
    For Each cell_selected In rng
        Index = cell_selected.Interior.colorIndex
        If Index = -4142 Then
            cell_selected.Range("N4").Value = "Free"
       
            Else
                cell_selected.Value.Range("N4").Value = "Busy"
       
        End If
   
    Next cell_selected
   
End Sub


Viewing all articles
Browse latest Browse all 50067

Trending Articles