Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 709
Default A macro code question from a novice

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
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 10,124
Default A macro code question from a novice

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")


--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"Richard" wrote in message
...
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


  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 10,593
Default A macro code question from a novice

- 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)



"Richard" wrote in message
...
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



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Novice formula question Denise Excel Discussion (Misc queries) 10 November 7th 07 08:43 AM
Novice IF and COUNT question (I think) Robin Excel Worksheet Functions 5 October 3rd 07 11:00 PM
Very Novice Excel user with security question Ralph Malph Excel Discussion (Misc queries) 5 March 23rd 06 06:33 PM
Excel Novice, Stupid Question, but help! [email protected] Excel Discussion (Misc queries) 6 February 13th 06 03:14 AM
drop down list - a question from novice striker_69 Excel Discussion (Misc queries) 5 September 19th 05 06:59 PM


All times are GMT +1. The time now is 03:38 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"