Tuesday, June 22, 2010

Microsoft Excel: Add A Pop-Up Picture To Multiple Cells

Problem: You gave this book to your manager for Boss’ Day. He saw the previous trick, about adding a pop-up picture to a cell, and wants you to add pictures to dozens of cells, as shown in Fig. 1192. Adding pictures is one of the most tedious tasks in Excel.

See all Microsoft Excel tips

Strategy: A VBA macro can be used to speed up a lot of jobs. I would never attempt this particular task without it, especially because the macro is so simple.

Enter these few lines of code in the VBA Editor. Select the dozens of cells. Run the macro. Pictures are added to every cell in the selection.Sub AddABunch()

For Each cell In Selection

MyPic = “C:\Qimage\QI” & cell.Value & “.jpg”

With cell.AddComment

.Shape.Fill.UserPicture MyPic

.Shape.Height = 300

.Shape.Width = 300

End With Next cell End Sub

Additional Details: For the complete guide to learning VBA, check out VBA & Macros for Microsoft Excel from QUE.

The above macro works because all of our company pictures are in the same folder with a common naming scheme.

Summary: A few lines of VBA code can turn a horribly monotonous jobinto a few seconds of work.

Commands Discussed: VBA

See all Microsoft Excel tips

Images

Fig. 1192



No comments:

Post a Comment

brings you the latest technology news, computer mods, computer news and the latest computer and notebook reviews.