View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Gord Dibben
 
Posts: n/a
Default Editing a simple macro

Connie

I see what you're doing with this macro but I don't understand why.

See comments in line

On Fri, 25 Nov 2005 12:58:01 -0800, "Connie Martin"
wrote:

Okay, great. That works. Although, dumb me, I just discovered I don't need
to unprotect the worksheet to copy cells! I was trying to do several things
with this macro and some of it I changed because no one was able to answer my
previous question "Recording Macro". I would you like to record typing text
in a cell, then copying it, then deleting it, password protecting the file
again, and ending. But I lose what's on the clipboard. There appears to be
no way to keep what I copied.

So, it would be like this:

ActiveSheet.Unprotect Password:="justme"

Range("B13:AG13").Select
ActiveCell.FormulaR1C1 = _
"This form is sent to you for your approval for special expediting."
& Chr(10) & "Please reply to sender and copy Valerie Hill and Connie Martin."
With ActiveCell.Characters(Start:=1, Length:=130).Font
.Name = "Arial"
.FontStyle = "Bold"
.Size = 14
.Strikethrough = False
.Superscript = False
.Subscript = False
.OutlineFont = False
.Shadow = False
.Underline = xlUnderlineStyleNone
.ColorIndex = xlAutomatic
End With

Formatted text is now in B13

Range("A13:AH20").Select
Selection.Copy

Copies A13:AH20 which includes the text in B13

Range("B13:AG13").Select
Application.CutCopyMode = False.
Selection.ClearContents

Clears contents from B13:AG13

Range("X21:AG22").Select

What are you going to do here?

End Sub

ActiveSheet.Protect Password:="justme"

This line fits in before End Sub, not after.

Is there any way to retain the copied text on the clipboard?

To do what with it?
EditClipboard shows me the copied contents.


Gord


"Gord Dibben" wrote:

ActiveSheet.Unprotect Password:="justme"

ActiveWindow.LargeScroll ToRight:=4
Range("HH12:IO19").Select
Selection.Copy
ActiveWindow.LargeScroll ToRight:=-4
ActiveWindow.SmallScroll Down:=9
Range("X20:AG21").Select

ActiveSheet.Protect Password:="justme"


Gord Dibben Excel MVP

On Fri, 25 Nov 2005 11:51:40 -0800, "Connie Martin"
wrote:

I have this simple macro, which works fine:

Sub CopyFormDM()
'
' CopyFormDM Macro
' Macro recorded 11/25/2005 by Connie Martin
'

'
ActiveWindow.LargeScroll ToRight:=4
Range("HH12:IO19").Select
Selection.Copy
ActiveWindow.LargeScroll ToRight:=-4
ActiveWindow.SmallScroll Down:=9
Range("X20:AG21").Select
End Sub

I would like to password protect the form and edit the macro so that part of
the macro is to unprotect the form first, run the rest of the macro and then
password protect it again before ending. When I recorded the macro that way
and then later ran it, it stopped for me to put in the password, and then
ended by protecting it without a password. I would like to edit the macro so
that it puts the password in to unprotect and puts it in again to protect. I
realize anyone looking at the macro in VB will see the password but this file
is to be used by people who most likely don't know how to do that, and if
they did, it would be no big harm done.

Thank you
Connie Martin