excel 用图像替换单元格值

798qvoo8  于 2023-01-03  发布在  其他
关注(0)|答案(1)|浏览(173)

我有一个Excel文件,其中的表包含值O和G。我想用橙子图标替换O,用绿色图标替换G
如何读取每个单元格的值O和G,并将它们替换为各自的图像?

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

owfi6suc

owfi6suc1#

你就是这么做的,

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

相关问题