Arkadaşlar,
Bir sayfada 8. satırdan başlayarak, F ve G hücrelerinde resim olup olmadığını denetleyecek,
her ikisinde de resim yoksa o satırı silecek, ikisinde de veya sadece herhangi birinde resim varsa
işlem yapmayacak bir koda ihtiyacım var.
Sayfaya resim attığım kodu da paylaşıyorum.
Yardımcı olacak arkadaşlara şimdiden teşekkür ederim.
Bir sayfada 8. satırdan başlayarak, F ve G hücrelerinde resim olup olmadığını denetleyecek,
her ikisinde de resim yoksa o satırı silecek, ikisinde de veya sadece herhangi birinde resim varsa
işlem yapmayacak bir koda ihtiyacım var.
Sayfaya resim attığım kodu da paylaşıyorum.
Yardımcı olacak arkadaşlara şimdiden teşekkür ederim.
Kod:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Sheets("20k").Select
If Sheets("20k").Range("a1") = "x" Then
If Intersect(Target, [D2:D100,G2:F100]) Is Nothing Then Exit Sub
yatay = 1 ' bu kadar hücre sağa kayacak
dikey = 0 ' bu kadar hücre aşağıya kayacak
Dim s1
Set s1 = Sheets(ActiveSheet.Name)
If InStr(Trim(ActiveWindow.RangeSelection.Address), ":") = 0 Then
Set Adres = s1.Cells(Target.Row + dikey, Target.Column + yatay)
Dim Picture As Object
For Each Picture In s1.Shapes
If TypeName(s1.Shapes(Picture.Name).OLEFormat.Object) = "Picture" Then
Set yer = s1.Cells(Picture.BottomRightCell.Row, Picture.BottomRightCell.Column)
If yer.Address = Adres.Address Then
Picture.Delete
Exit For
End If
End If
Next Picture
ReDim uzanti(11)
uzanti(1) = "bmp": uzanti(2) = "jpg"
uzanti(3) = "gif": uzanti(4) = "png"
uzanti(5) = "jpeg"
For j = 1 To 5
dosya = ThisWorkbook.Path & "\Azmun\Sorular\" & Target.Value & "." & uzanti(Val(j))
If CreateObject("Scripting.FileSystemObject").FileExists(dosya) = True Then
ad = s1.Pictures.Insert(dosya).Name
s1.Shapes(ad).OLEFormat.Object.ShapeRange.LockAspectRatio = msoFalse
s1.Shapes(ad).OLEFormat.Object.Top = Adres.Top + 3
s1.Shapes(ad).OLEFormat.Object.Left = Adres.Left + 3
s1.Shapes(ad).OLEFormat.Object.ShapeRange.Height = Adres.Height - 50
s1.Shapes(ad).OLEFormat.Object.ShapeRange.Width = Adres.Width - 30
s1.Shapes(ad).OLEFormat.Object.Name = Target.Address
s1.Cells(Target.Row + 1, Target.Column).Select
Exit For
End If
Next
End If
Else
Exit Sub
End If
End Sub
Son düzenleme:
