View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
Norman Jones Norman Jones is offline
external usenet poster
 
Posts: 5,302
Default Picture in Cell of Active Sheet

Hi Sige,

Can the picture resize as well? If cell-size (A1) changes the picture
changes with ...?


In a standard module, paste the following sub:

'===================
Sub RunOnce()
Dim sh As Worksheet

For Each sh In ActiveWorkbook.Worksheets
If sh.Name < "YOUR HIDDEN SHEET NAME" Then
On Error Resume Next
sh.Pictures.Delete
On Error GoTo 0
End If
Next sh

End Sub
'<<===================

Please run this sub *once*, Change "YOUR HIDDEN SHEET NAME" to the
requisite sheet name.

Then replace your existing Workbook_SheetActivate code with this revised
version:

'===================
Private Sub Workbook_SheetActivate(ByVal sh As Object)
Dim pic As Picture
Dim WS As Worksheet
Dim rng As Range
Set WS = Sheets("YOUR HIDDEN SHEET NAME")
Set rng = sh.Range("A1")

If sh.Name < WS.Name Then
If sh.Pictures.Count = 0 Then
Set pic = WS.Pictures("Picture 5")
pic.CopyPicture
sh.Paste Destination:=rng

With sh.Pictures(1)
.Top = rng.Top
.Left = rng.Left
.Height = rng.Rows(1).RowHeight
.Width = rng.EntireColumn.Width
.Placement = xlMoveAndSize
End With
End If
End If
End Sub
'<<===================


---
Regards,
Norman



"Sige" wrote in message
oups.com...
Beautiful Norman!

Can the picture resize as well? If cell-size (A1) changes the picture
changes with ...?

Brgds Sige