- Katılım
- 21 Şubat 2007
- Mesajlar
- 24
- Excel Vers. ve Dili
- Office Professional Plus 2019 Türkçe
- Altın Üyelik Bitiş Tarihi
- 11-01-2025
Arkadaşlar aşağıda ki kodla sadece b2 hücresine ID girince a2 hücresine resim getiriyor.
Benim yapmak istediğim b2:b1000 arası satırlara ID girince aynı şekilde a2:a1000 satırlarına resmi getirmek.
Yaptığım bazı değişikliklerle başarılı olamadım. Oluşan hatalar b3 hücresine veri girdiğimde b2 de ki görselin silinmesi gibi sonuçlar aldım.
Yardımlarınız için şimdiden teşekkür ederim.
Private Sub Worksheet_Change(ByVal Target As Range)
If Intersect(Target, [b2]) Is Nothing Then Exit Sub
On Error Resume Next
ActiveSheet.DrawingObjects.Delete
Set fso = VBA.CreateObject("scripting.filesystemobject")
resimyolu = "C:\RESİM\" & Range("b2") & ".jpg"
resimsiz = "C:\RESİM\" & "RESİMSİZ.jpg"
If Not fso.fileexists(resimyolu) Then
Set resimyok = ActiveSheet.Pictures.Insert(resimsiz)
With Range("a2")
resimyok.Top = Range("a2").Top
resimyok.Left = Range("a2").Left
resimyok.ShapeRange.LockAspectRatio = msoFalse
resimyok.Height = 112
resimyok.Width = 84
End With
Else
Set Resim = ActiveSheet.Pictures.Insert(resimyolu)
With Range("a2")
Resim.Top = Range("a2").Top
Resim.Left = Range("a2").Left
Resim.ShapeRange.LockAspectRatio = msoFalse
Resim.Height = 112
Resim.Width = 84
End With
End If
End Sub
Benim yapmak istediğim b2:b1000 arası satırlara ID girince aynı şekilde a2:a1000 satırlarına resmi getirmek.
Yaptığım bazı değişikliklerle başarılı olamadım. Oluşan hatalar b3 hücresine veri girdiğimde b2 de ki görselin silinmesi gibi sonuçlar aldım.
Yardımlarınız için şimdiden teşekkür ederim.
Private Sub Worksheet_Change(ByVal Target As Range)
If Intersect(Target, [b2]) Is Nothing Then Exit Sub
On Error Resume Next
ActiveSheet.DrawingObjects.Delete
Set fso = VBA.CreateObject("scripting.filesystemobject")
resimyolu = "C:\RESİM\" & Range("b2") & ".jpg"
resimsiz = "C:\RESİM\" & "RESİMSİZ.jpg"
If Not fso.fileexists(resimyolu) Then
Set resimyok = ActiveSheet.Pictures.Insert(resimsiz)
With Range("a2")
resimyok.Top = Range("a2").Top
resimyok.Left = Range("a2").Left
resimyok.ShapeRange.LockAspectRatio = msoFalse
resimyok.Height = 112
resimyok.Width = 84
End With
Else
Set Resim = ActiveSheet.Pictures.Insert(resimyolu)
With Range("a2")
Resim.Top = Range("a2").Top
Resim.Left = Range("a2").Left
Resim.ShapeRange.LockAspectRatio = msoFalse
Resim.Height = 112
Resim.Width = 84
End With
End If
End Sub