Please Note: This article is written for users of the following Microsoft Excel versions: 2007 and 2010. If you are using an earlier version (Excel 2003 or earlier), this tip may not work for you. For a version of this tip written specifically for earlier versions of Excel, click here: Copying Pictures with a Macro.
by Allen Wyatt
(last updated May 10, 2016)
Lowell developed a macro to copy select cells' data to a specific location on another worksheet. Some of the source cells contain pictures, and he would like those pictures copied, as well. Lowell wonders how he can get the macro to recognize if a picture is at the source cell and then copy the pictures to the new worksheet along with the data.
If you use the Copy method with the Selection object, you can copy everything—including pictures—from your source to your target. Consider the following short macro:
Sub CopyPict() Sheets("Sheet1").Select Range("B3:F7").Select Selection.Copy Sheets("Sheet3").Select Range("H8").Select ActiveSheet.Paste End Sub
Assuming that some of the cells within the source range (B3:B7 on Sheet1) contain pictures, then the Paste method will paste those into the target (cell H8 on Sheet3). This technique is, in fact, the same as using copy and paste manually with the information.
If you are identifying and moving information in a different manner (perhaps using an intermediary variable instead of copying to the Clipboard), then it is very possible that the pictures aren't copying. If you need to do some processing of the data before pasting it into the target, you could use the Paste method, as shown above, and then process the data and place it back into the target cell. That would allow the pictures to remain undisturbed at the target.
ExcelTips is your source for cost-effective Microsoft Excel training. This tip (11333) applies to Microsoft Excel 2007 and 2010. You can find a version of this tip for the older menu interface of Excel here: Copying Pictures with a Macro.
Create Custom Apps with VBA! Discover how to extend the capabilities of Office 2013 (Word, Excel, PowerPoint, Outlook, and Access) with VBA programming, using it for writing macros, automating Office applications, and creating custom applications. Check out Mastering VBA for Office 2013 today!
Need to normalize your data in some way so that all your values are in a given format? This tip presents a number of ...Discover More
Part of writing macros is to make sure they work as you expect. This involves a process known as debugging. Here's how you ...Discover More
When sharing workbooks with others, you may find that the macros in those workbooks may not work as you expect. This tip ...Discover More
FREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."
Got a version of Excel that uses the ribbon interface (Excel 2007 or later)? This site is for you! If you use an earlier version of Excel, visit our ExcelTips site focusing on the menu interface.