0
我有流動的代碼設置,我可以從一個數字從1到10插入一個數字到單元格A1:J1中。然後我有10個圖片對應於1到10的數字。所以如果我把數字1插入A1,與它相關的圖像顯示在它下面。這適用於A1:J1範圍內的所有單元格。現在我的問題是,如果我在A1中輸入1,然後在單元格C1中輸入另一個1,則圖像從單元格A1下移動到C1下方。我希望它能夠像A1:J1範圍內的所有數字一樣,然後在所有這些數字下面顯示相同的圖片。自動顯示圖片
Private Sub Worksheet_Change(ByVal Target As Range)
Dim rngCell As Range
Me.Pictures.Visible = False
Application.EnableEvents = False
If Not Application.Intersect(Target, Me.Range("A1:J1")) Is Nothing Then
For Each rngCell In Me.Range("A1:J1")
On Error Resume Next
Me.Pictures("BldgA" & rngCell.Value).Visible = True
Me.Pictures("BldgA" & rngCell.Value).Top = rngCell.Offset(1).Top
Me.Pictures("BldgA" & rngCell.Value).Left = rngCell.Offset(1).Left
Err.Clear: On Error GoTo -1: On Error GoTo 0
Next rngCell
End If
Application.EnableEvents = True
End Sub