Ho un file Excel con una tabella contenente i valori O e G, voglio usare una macro per sostituire O con un'icona arancione e G con un'icona verde
Non so come leggere ogni cella per il valore O e G e sostituirli con la rispettiva immagine.
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
risposte:
0 per risposta № 1Questo è come lo fai,
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