iplikci_80
Altın Üye
- Katılım
- 29 Kasım 2007
- Mesajlar
- 1,110
- Excel Vers. ve Dili
- excel 2007
DOSYA İndirmek/Yüklemek için ÜCRETLİ ALTIN ÜYELİK Gereklidir!
Altın Üyelik Hakkında Bilgi
Private Sub Worksheet_Change(ByVal Target As Range)
If Intersect(Target, [M1]) Is Nothing Then Exit Sub
On Error GoTo Git
ActiveSheet.DrawingObjects.Delete
Dim ResimYolu As Variant
Dim Resim As Object
ResimYolu = ActiveWorkbook.Path & "\" & Range("M1") & ".jpg"
Set Resim = ActiveSheet.Pictures.Insert(ResimYolu)
With Range("I1:K2")
Resim.ShapeRange.LockAspectRatio = msoFalse
Resim.Top = .Top
Resim.Left = .Left
Resim.Height = .Height
Resim.Width = .Width
End With
Git:
End Sub
Private Sub Worksheet_Change(ByVal Target As Range)
ActiveSheet.Unprotect
If Intersect(Target, [N1]) Is Nothing Then Exit Sub
On Error GoTo Git
Dim ResimYolu As Variant
Dim Resim As Object
DrawingObjects.Delete
ResimYolu = ActiveWorkbook.Path & "\" & Range("N1") & ".jpg"
Set Resim = Pictures.Insert(ResimYolu)
With Range("J3:K3")
Resim.ShapeRange.LockAspectRatio = msoFalse
Resim.Top = .Top
Resim.Left = .Left
Resim.Height = .Height
Resim.Width = .Width
End With
Git:
ActiveSheet.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True
End Sub
Private Sub Worksheet_Change(ByVal Target As Range)
ActiveSheet.Unprotect
If Intersect(Target, [N1]) Is Nothing Then Exit Sub
On Error GoTo Git
Dim ResimYolu As Variant
Dim Resim As Object
DrawingObjects.Delete
ResimYolu = ActiveWorkbook.Path & "\" & Range("N1") & ".jpg"
If Dir(ResimYolu) = "" Then ResimYolu = ActiveWorkbook.Path & "\RESİM YOK.jpg"
Set Resim = Pictures.Insert(ResimYolu)
With Range("J3:K3")
Resim.ShapeRange.LockAspectRatio = msoFalse
Resim.Top = .Top
Resim.Left = .Left
Resim.Height = .Height
Resim.Width = .Width
End With
Git:
ActiveSheet.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True
End Sub
Private Sub Worksheet_Change(ByVal Target As Range)
On Error GoTo CIKIS
If Intersect(Target, [B23:B80]) Is Nothing Then Exit Sub
Satir = Target.Row
a = RESIM_SIL(Satir)
If Range("B" & Satir).Value = "" Then Exit Sub
a = RESIM_EKLE(Satir)
Exit Sub
CIKIS:
MsgBox Err.Description
End Sub
Public Function RESIM_EKLE(pSatir)
On Error GoTo Hata
Dim ResimYolu, dosyaVarmi As Variant
Dim Resim As Object
ResimYolu = "C:\Users\Kullanıcı\Desktop\RESİMLER\" & Range("B" & pSatir).Value & ".jpg"
dosyaVarmi = Dir(ResimYolu)
If dosyaVarmi = "" Then
ResimYolu = "C:\Users\Kullanıcı\Desktop\RESİMLER\bos.jpg"
End If
Set Resim = ActiveSheet.Pictures.Insert(ResimYolu)
' Resim boyutlama
Range("U" & pSatir).Value = Resim.Name
With Range("G" & pSatir)
Resim.ShapeRange.LockAspectRatio = msoFalse
Resim.Left = .Left + 2
Resim.Top = .Top + 1
Resim.Height = .Height - 2
Resim.Width = .Width - 5
End With
Exit Function
Hata:
MsgBox "Hata Oluştu" & vbNewLine & Err.Description
End Function
Public Function RESIM_SIL(pSatir)
On Error GoTo Hata
ActiveSheet.Shapes.Range(Array(Range("U" & pSatir).Value)).Select
Selection.Delete
Hata:
Range("U" & pSatir).Value = ""
End Function
Merhabalar.
Konu çözüldümü bilmüyorum ama alternatif olarak bu formülüde kullanabilirsiniz.
Kendi dosyanıza ve adres yolunuza uygulamanız lazım. Değişmeniz ve dikkat etmeniz gerekenleride aşağıda listeledim
Aşağıdaki koda göre ;
Not : Eğer dosyanızda satır sayısı fazla ise muhakkak resim boyutlarını küçültün. Aksi takdirde hem çok fazla kasacaktır hem dosya kullanılamaz hale gelecektir. ( PIXresizer Kullanabilirsiniz )
- B sütunundaki kod ile resmin adı aynı olmalı
- B23-B80 arasına bakıp resimleri karşılık gelen G sütununa ekler
- C:\Users\Kullanıcı\Desktop\RESİMLER Resimlerin olduğu klasör yolu
- U sütununa resimlerin exceldeki adlarını getirttir – Bu ada göre G sütunundaki resmi siler.
- Resim boyutlandırmada + - sayılar belirterek resmin konumunu ayarla.
- Resimlerin olduğu klasörde "bos" adı ile bir resim koyarsanız resmi bulunmayan kod için bu resmi getirir.
- Resimler jpg formatında olmalıdır.
Kod:Private Sub Worksheet_Change(ByVal Target As Range) On Error GoTo CIKIS If Intersect(Target, [B23:B80]) Is Nothing Then Exit Sub Satir = Target.Row a = RESIM_SIL(Satir) If Range("B" & Satir).Value = "" Then Exit Sub a = RESIM_EKLE(Satir) Exit Sub CIKIS: MsgBox Err.Description End Sub Public Function RESIM_EKLE(pSatir) On Error GoTo Hata Dim ResimYolu, dosyaVarmi As Variant Dim Resim As Object ResimYolu = "C:\Users\Kullanıcı\Desktop\RESİMLER\" & Range("B" & pSatir).Value & ".jpg" dosyaVarmi = Dir(ResimYolu) If dosyaVarmi = "" Then ResimYolu = "C:\Users\Kullanıcı\Desktop\RESİMLER\bos.jpg" End If Set Resim = ActiveSheet.Pictures.Insert(ResimYolu) ' Resim boyutlama Range("U" & pSatir).Value = Resim.Name With Range("G" & pSatir) Resim.ShapeRange.LockAspectRatio = msoFalse Resim.Left = .Left + 2 Resim.Top = .Top + 1 Resim.Height = .Height - 2 Resim.Width = .Width - 5 End With Exit Function Hata: MsgBox "Hata Oluştu" & vbNewLine & Err.Description End Function Public Function RESIM_SIL(pSatir) On Error GoTo Hata ActiveSheet.Shapes.Range(Array(Range("U" & pSatir).Value)).Select Selection.Delete Hata: Range("U" & pSatir).Value = "" End Function
Sayın ThaLees
Bu kodları satıra dönüştürebilirmiyiz peki. Siz satır satır eklemişsiniz ben kolonlara doğru yatay resim eklemek istiyorum.
Private Sub TexARA_Change() 'Sipariş numarası ara
resimYol = ThisWorkbook.Path & "\Resimler\"
Resimler = Dir(resimYol & "*.*")
resim = 0
While Resimler <> ""
DoEvents
resimlerAd = Mid(Resimler, 1, Len(Resimler) - 4)
If resimlerAd = Me.TexARA.Text Then
Me.Image1.Picture = LoadPicture(resimYol & Resimler)
resim = 1
End If
Resimler = Dir
Wend
If resim = 0 Then Me.Image1.Picture = LoadPicture(resimYol & "RESİM YOK.jpg")
End Sub