View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
Eric Eric is offline
external usenet poster
 
Posts: 1,670
Default How to automatically trigger the vba coding by opening workshe

Do you mean to change the following coding like this?
I try it, but error message occurs about "Cannot find method or data ..."
Do you have any suggestions?
Thank you very much for any suggestions
Eric

Private Sub Workbook_Open()
Sheet3.Worksheet_Change ([A1])
End Sub

'---------------------------------------------------------
'---Private in front of Sub Worksheet_Change has been removed.
Sub Worksheet_Change(ByVal Target As Range)

Dim myPic1 As Object
Dim myPic2 As Object
Dim myPic3 As Object
Dim dblTop As Double
Dim dblLeft As Double
Dim dblHeight As Double
Dim dblWidth As Double

If Target.Address = "$A$1" Then
On Error Resume Next
Set myPic1 = ActiveSheet.Pictures("PicAtB10")
Set myPic2 = ActiveSheet.Pictures("PicAtE10")
Set myPic3 = ActiveSheet.Pictures("PicAtH10")
On Error GoTo 0
If Not myPic1 Is Nothing Then myPic1.Delete
If Not myPic2 Is Nothing Then myPic2.Delete
If Not myPic3 Is Nothing Then myPic3.Delete

"Phil Hibbs" wrote:

If I understand you right, you want the Worksheet_Change sub to be
called when the workbook opens? Just remove the "Private" from the
declaration, then make a Workbook_Open sub in the ThisWorkbook code
area like this:

Private Sub Workbook_Open()
Sheet1.Worksheet_Change ([A1])
End Sub

Phil Hibbs.
.