'Replace cell value with image

I have an Excel file with a table containing values O and G. I want to replace O with an orange icon and G with a green icon

How do I read each cell for value O and G and replace them with their respective image?

Private Sub CommandButton1_Click()

For Each c In Worksheets("Summary (2)").Range("A1:D10")
    If c.Value = 0 Then
        c.Value = Orange
    ElseIf c.Value = G Then
        c.Value = "Green"
    Else
        c.Value = ""
    End If
Next c
End Sub

enter image description here



Solution 1:[1]

This is how you do it,

Private Sub CommandButton1_Click()   

Application.CopyObjectsWithCells = True
For Each c In Worksheets("Sector Summary (2)").Range("A1:H100")
 If c.Value = "O" Then
     Sheets("master").Cells(1, 2).Copy
     c.Select
     ActiveSheet.Paste

 ElseIf c.Value = "G" Then
     Sheets("master").Cells(2, 2).Copy
     c.Select
     ActiveSheet.Paste

 ElseIf c.Value = "R" Then
     Sheets("master").Cells(3, 2).Copy
     c.Select
     ActiveSheet.Paste
 Else
      c.Value = c.Value
 End If
Next c
End Sub

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Tushar Narang