Hello every one !
I am trying to update my report by deleting the old phot and insert a new photo meanning , if (Case testRange.Value2 < 1#) then delete the old photo in the cell which is (Attach) and insert
picname = "C:\Users\MAlhashlamoun\Pictures\UNATTACH" & ".png" also for the other condition if Case testRange.Value2 >= 1#, delete the photo exisiting in the same cell and replace with picname = "C:\Users\MAlhashlamoun\Pictures\ATTACH" & ".png"
This is my code:
Sub Update_Click()
Application.ScreenUpdating = True
Dim testRange As Range
Dim picname As String
Set testRange = ActiveSheet.Range("O95")
If IsEmpty(testRange) Then
MsgBox "No value in cell O95"
Exit Sub
End If
Select Case True
Case Not IsNumeric(testRange.Value2)
MsgBox "Value in cell O95 is not numeric"
Exit Sub
Case testRange.Value2 < 1#
picname = "C:\Users\MAlhashlamoun\Pictures\UNATTACH" & ".png"
Case testRange.Value2 >= 1#
picname = "C:\Users\MAlhashlamoun\Pictures\ATTACH" & ".png"
End Select
On Error GoTo ErrNoPhoto
ActiveSheet.Pictures.Insert(picname).Select
With Selection
.Left = Range("R95").Left
.Top = Range("R95").Top
.ShapeRange.IncrementLeft 38
.ShapeRange.IncrementTop 5
.ShapeRange.LockAspectRatio = msoFalse
.ShapeRange.Height = 20#
.ShapeRange.Width = 20#
.ShapeRange.Rotation = 0#
End With
Application.ScreenUpdating = True
Exit Sub
ErrNoPhoto:
MsgBox "Unable to Find Photo" 'Shows message box if picture not found
Exit Sub
End Sub
I am trying to update my report by deleting the old phot and insert a new photo meanning , if (Case testRange.Value2 < 1#) then delete the old photo in the cell which is (Attach) and insert
picname = "C:\Users\MAlhashlamoun\Pictures\UNATTACH" & ".png" also for the other condition if Case testRange.Value2 >= 1#, delete the photo exisiting in the same cell and replace with picname = "C:\Users\MAlhashlamoun\Pictures\ATTACH" & ".png"
This is my code:
Sub Update_Click()
Application.ScreenUpdating = True
Dim testRange As Range
Dim picname As String
Set testRange = ActiveSheet.Range("O95")
If IsEmpty(testRange) Then
MsgBox "No value in cell O95"
Exit Sub
End If
Select Case True
Case Not IsNumeric(testRange.Value2)
MsgBox "Value in cell O95 is not numeric"
Exit Sub
Case testRange.Value2 < 1#
picname = "C:\Users\MAlhashlamoun\Pictures\UNATTACH" & ".png"
Case testRange.Value2 >= 1#
picname = "C:\Users\MAlhashlamoun\Pictures\ATTACH" & ".png"
End Select
On Error GoTo ErrNoPhoto
ActiveSheet.Pictures.Insert(picname).Select
With Selection
.Left = Range("R95").Left
.Top = Range("R95").Top
.ShapeRange.IncrementLeft 38
.ShapeRange.IncrementTop 5
.ShapeRange.LockAspectRatio = msoFalse
.ShapeRange.Height = 20#
.ShapeRange.Width = 20#
.ShapeRange.Rotation = 0#
End With
Application.ScreenUpdating = True
Exit Sub
ErrNoPhoto:
MsgBox "Unable to Find Photo" 'Shows message box if picture not found
Exit Sub
End Sub