Graphics question

P

Patrick C. Simonds

Is it possible to place a series of graphics (I have created 1 for each of
our allowed holidays) on a worksheet, and then using code copy the graphic
to another worksheet in the same workbook?

I have created a Template for our vacation calendar so we do not have
recreate it each year. When I start a new year I have conditional formatting
which removes all lines on the calendar for each of the holidays. Then I
want to paste the holidays graphic on the calendar. So say for Christmas I
have a graphic which is named Christmas.gif which I have inserted on a blank
(hidden) worksheet which I would copy to cell B44.

I envision having SheetActivation code which would look something like:

If range ("B60").value = "Christmas" Then

and then the code to copy the graphic Christmas from the hidden holiday
worksheet to cell B44 of the active worksheet.
 
P

Patrick C. Simonds

Yes, it does not record what is being selected:


Sub Macro1()
'
' Macro1 Macro
'

'
Selection.Copy
Sheets("01 Jan 09").Select
Range("AJ22").Select
ActiveSheet.Paste
End Sub
 
P

Peter T

Following should copy/paste to same position within topleftcell of the
source shape, not necessarily same left & top if row/column widths are
different on respective sheets (otherwise simply copy left/top properties of
source shape to the dest' shape). No sheet or shape selection required.

Sub test()
Dim lt As Single, tp As Single
Dim rTL As Range
Dim shp As Shape

Set shp = ActiveWorkbook.Worksheets("Sheet1").Shapes("Christmas")

With shp
Set rTL = .TopLeftCell
lt = .Left - rTL.Left
tp = .Top - rTL.Top
.Copy
End With

With ActiveWorkbook.Worksheets("Sheet2")
.Paste
Set rTL = .Range(rTL.Address)
With .Shapes(.Shapes.Count)
.Left = rTL.Left + lt
.Top = rTL.Top + tp
End With
End With

End Sub

Regards,
Peter T
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top