Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
nc nc is offline
external usenet poster
 
Posts: 119
Default Copy & paste to protected sheet

I am using the macro below, where would I insert the unprotect and protect
statement for the sheet "Transactions", the latter is protected.


sub CopyStatement()

Dim LastRow As Long


CopyStatementMsg = MsgBox("Are you sure you want to Copy Statement to
Transactions Sheet?", vbYesNo + vbDefaultButton2)

If CopyStatementMsg = vbNo Then End

Application.ScreenUpdating = False

ActiveSheet.Unprotect


ActiveSheet.UsedRange
LastRow = Cells.SpecialCells(xlLastCell).Row
LastRow = Cells(Cells.Rows.Count, "W").End(xlUp).Row
ActiveSheet.Range("$S$5:$W" & LastRow).Copy
Sheets("Transactions").Range("A13").PasteSpecial Paste:=xlValues
ActiveSheet.Protect

Sheets("Transactions").Activate
Range("F13").Select


Application.ScreenUpdating = True


End Sub
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 3,346
Default Copy & paste to protected sheet

Hi,

Avoid this issue by programatically protecting the worksheet and using the
ActiveSheet.Protect Password:="x", UserInterfaceOnly:=True

You can run this as a stand alone macro or you can incorporate this into a
Workbook_Open procedure.

--
If this helps, please click the Yes button.

Cheers,
Shane Devenshire


"nc" wrote:

I am using the macro below, where would I insert the unprotect and protect
statement for the sheet "Transactions", the latter is protected.


sub CopyStatement()

Dim LastRow As Long


CopyStatementMsg = MsgBox("Are you sure you want to Copy Statement to
Transactions Sheet?", vbYesNo + vbDefaultButton2)

If CopyStatementMsg = vbNo Then End

Application.ScreenUpdating = False

ActiveSheet.Unprotect


ActiveSheet.UsedRange
LastRow = Cells.SpecialCells(xlLastCell).Row
LastRow = Cells(Cells.Rows.Count, "W").End(xlUp).Row
ActiveSheet.Range("$S$5:$W" & LastRow).Copy
Sheets("Transactions").Range("A13").PasteSpecial Paste:=xlValues
ActiveSheet.Protect

Sheets("Transactions").Activate
Range("F13").Select


Application.ScreenUpdating = True


End Sub

  #3   Report Post  
Posted to microsoft.public.excel.misc
nc nc is offline
external usenet poster
 
Posts: 119
Default Copy & paste to protected sheet

Sorry, your answer was not helpful.

Basically I am just protecting the worksheets with formulas to avoid
accidentally deleting them.


"Shane Devenshire" wrote:

Hi,

Avoid this issue by programatically protecting the worksheet and using the
ActiveSheet.Protect Password:="x", UserInterfaceOnly:=True

You can run this as a stand alone macro or you can incorporate this into a
Workbook_Open procedure.

--
If this helps, please click the Yes button.

Cheers,
Shane Devenshire


"nc" wrote:

I am using the macro below, where would I insert the unprotect and protect
statement for the sheet "Transactions", the latter is protected.


sub CopyStatement()

Dim LastRow As Long


CopyStatementMsg = MsgBox("Are you sure you want to Copy Statement to
Transactions Sheet?", vbYesNo + vbDefaultButton2)

If CopyStatementMsg = vbNo Then End

Application.ScreenUpdating = False

ActiveSheet.Unprotect


ActiveSheet.UsedRange
LastRow = Cells.SpecialCells(xlLastCell).Row
LastRow = Cells(Cells.Rows.Count, "W").End(xlUp).Row
ActiveSheet.Range("$S$5:$W" & LastRow).Copy
Sheets("Transactions").Range("A13").PasteSpecial Paste:=xlValues
ActiveSheet.Protect

Sheets("Transactions").Activate
Range("F13").Select


Application.ScreenUpdating = True


End Sub

  #4   Report Post  
Posted to microsoft.public.excel.misc
nc nc is offline
external usenet poster
 
Posts: 119
Default Copy & paste to protected sheet

I used

Worksheets("Transactions").Unprotect

It worked.



"Shane Devenshire" wrote:

Hi,

Avoid this issue by programatically protecting the worksheet and using the
ActiveSheet.Protect Password:="x", UserInterfaceOnly:=True

You can run this as a stand alone macro or you can incorporate this into a
Workbook_Open procedure.

--
If this helps, please click the Yes button.

Cheers,
Shane Devenshire


"nc" wrote:

I am using the macro below, where would I insert the unprotect and protect
statement for the sheet "Transactions", the latter is protected.


sub CopyStatement()

Dim LastRow As Long


CopyStatementMsg = MsgBox("Are you sure you want to Copy Statement to
Transactions Sheet?", vbYesNo + vbDefaultButton2)

If CopyStatementMsg = vbNo Then End

Application.ScreenUpdating = False

ActiveSheet.Unprotect


ActiveSheet.UsedRange
LastRow = Cells.SpecialCells(xlLastCell).Row
LastRow = Cells(Cells.Rows.Count, "W").End(xlUp).Row
ActiveSheet.Range("$S$5:$W" & LastRow).Copy
Sheets("Transactions").Range("A13").PasteSpecial Paste:=xlValues
ActiveSheet.Protect

Sheets("Transactions").Activate
Range("F13").Select


Application.ScreenUpdating = True


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
Copy paste Macro in a Protected Sheet [email protected] Excel Discussion (Misc queries) 1 January 9th 09 02:16 AM
How copy/paste values in Excel doc protected sheet 2 other doc? Got my CWC[_2_] Excel Discussion (Misc queries) 4 October 4th 08 01:28 AM
Do not allow Copy/Paste Functionality in a Protected Sheet Prashanth KR Excel Worksheet Functions 1 October 29th 07 06:12 PM
How to disable copy and paste function in a protected sheet Igneshwara reddy[_2_] Setting up and Configuration of Excel 1 March 17th 07 04:08 AM
How to copy/paste info into the protected sheet Dajana Excel Discussion (Misc queries) 1 September 21st 05 04:26 PM


All times are GMT +1. The time now is 02:31 AM.

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"