Insert same image into 2 seperate sheets. How?

hitme

New Member
Joined
Feb 4, 2013
Messages
16
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
 

Excel Facts

Excel Joke
Why can't spreadsheets drive cars? They crash too often!

Forum statistics

Threads
1,215,647
Messages
6,126,005
Members
449,279
Latest member
Faraz5023

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top