Select Worksheet Code
I'm not a VBA code person, however I have been mostly succesfull with copying
and pasting code from everyone's help here, much appreciated. I'm having
trouble with the following code:
Option Explicit
Private Sub Worksheet_Calculate()
ActiveSheet.Unprotect Password:="Profit"
Dim oPic As Picture
Me.Pictures.Visible = False
With Range("C2")
For Each oPic In Me.Pictures
If oPic.Name = .Text Then
oPic.Visible = True
oPic.Top = .Top
oPic.Left = .Left
Exit For
End If
Next oPic
End With
ActiveSheet.Protect Password:="Profit"
End Sub
The code works great on the sheet (Loan Package ENG) I want it to. On the
VBA editor this code is shown on Sheet4 (Loan Package ENG). However when I
enter data on a seperate sheet, I get:
Run-time error '1004':
Unable to set the Top property of the Picture class
When I click the Debug option, it takes me to the code above with 'oPic.Top
= .Top' highlighted.
I would like some help fixing this with correct code, but also a bit of an
explanation of why the error is occuring to help me understand VBA better.
Thanks
|