A macro code question from a novice

R

Richard

The following is my code for a macro I want to run on a protected worksheet.
My intent is for the macro to first unprotect the worksheet, then insert a
copy of the person's scanned signature on to the worksheet after they answer
the question "Are you sure you want to sign your timecard?", and then
reprotect the worksheet. When the code runs, I'm getting an error message
"Compile error: Expected End Sub". I'm sure it's due to a mistake (or more
than one) I've made. If anyone has time, would you please help me locate my
error(s)?

Thanks and have a wonderful holiday season!

Sub KSmith_signature()
'
' KSmith_signature Macro
' Macro recorded 12/24/2007 by Richard
'

'
Worksheets(SMITH.XLS).Unprotect Password:="simple"
Sub AskAndDo()
If MsgBox("Are you sure you want to sign your timecard?", vbYesNo +
vbQuestion) = vbNo Then Exit Sub
Else
Sheets("Sheet3").Select
ActiveSheet.Shapes("Picture 2").Select
Selection.Copy
Sheets("Master").Select
Range("A32:I34").Select
ActiveSheet.Paste
Selection.ShapeRange.IncrementLeft 54.75
Range("I26").Select
End If
End Sub
Worksheets(BEARDSLEE.XLS).Protect Password:="simple"
End Sub
 
D

Don Guillett

The basic problem is that you have a sub withIN a sub without an end.
Remove the
Sub AskAndDo()
line and then try to clean up your sub by removing selections, IF possible.

Sheets("Sheet3").Shapes("Picture 2").Copy _
Sheets("Master").Range("A32:I34")
 
B

Bob Phillips

- worksheets are not (normally) suffixed with .xls

- worksheets names are usually enclosed in quotes unless you really are
using a variable

- why unprotect one sheet, do things on other totally unrelated sheets, then
finally protect another one altogether

- you paste a shape and then locate it


Sub KSmith_signature()
If MsgBox("Are you sure you want to sign your timecard?", vbYesNo +
vbQuestion) = vbNo Then
Exit Sub
Else
Sheets("Sheet3").Shapes("Picture 2").Copy
With Sheets("Master")
.Paste
.Shapes("Picture 2").Left = Range("A32").Left
.Shapes("Picture 2").Top = Range("A32").Top
End With
End If
End Sub
--
---
HTH

Bob


(there's no email, no snail mail, but somewhere should be gmail in my addy)
 

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