I am trying to import the same image into 2 selected sheets at specified cells. Union range function keeps returning error. Can anyone help please? Desperate for quick reply!
Code:
Private Sub CommandButton11_Click()
Dim myPicture As String, myRange As Range
myPicture = Application.GetOpenFilename _
("Pictures (*.gif; *.jpg; *.bmp; *.tif),*.gif; *.jpg; *.bmp; *.tif", _
, "Select Picture to Import")
Set myRange = Union(Worksheets("RF Report").Range("H17"), Worksheets("R Report").Range("B12"))
InsertAndSizePic myRange, myPicture
End Sub
Sub InsertAndSizePic(Target As Range, PicPath As String)
Dim p As Picture, p1, p2
Application.ScreenUpdating = False
Set p1 = Sheets("RF Report").Pictures.Insert(PicPath)
Set p2 = Sheets("R Report").Pictures.Insert(PicPath)
Set p = Union(p1, p2)
If Target.Cells.Count = 1 Then Set Target = Target.MergeArea
With Target
p.Top = .Top
p.Left = .Left
p.Width = .Width
p.Height = .Height
End With
End Sub