|
|
macro to unlock and lock cells in password protected sheet
Hi all
Is there any way I can get a macro to unlock cell, paste valuse and the lock
again after completion. I have a macro to transfer valuse from one rang to
another. The macro will work ok if I leave the input cells unlocked. I would
like to be able to lock these cells so they can't be changed without the the
use of the macro. The input cells are F23:F23. See Code Below.
Regards
Chris
Sub update()
Worksheets(13).Range("I20:I23").Copy
Worksheets(13).Range("F20:23").PasteSpecial Paste:=xlPasteValues
Application.CutCopyMode = False
End Sub
|
|
0
|
|
|
|
Reply
|
Utf
|
2/26/2010 12:56:01 PM |
|
Hi,
Mabe this. Note the password is case sensitive
Sub update()
With Worksheets(13)
.Unprotect Password:="Mypass"
.Range("I20:I23").Copy
.Range("F20:F23").PasteSpecial Paste:=xlPasteValues
.Protect Password:="Mypass"
End With
Application.CutCopyMode = False
End Sub
--
Mike
When competing hypotheses are otherwise equal, adopt the hypothesis that
introduces the fewest assumptions while still sufficiently answering the
question.
"Chris" wrote:
> Hi all
>
> Is there any way I can get a macro to unlock cell, paste valuse and the lock
> again after completion. I have a macro to transfer valuse from one rang to
> another. The macro will work ok if I leave the input cells unlocked. I would
> like to be able to lock these cells so they can't be changed without the the
> use of the macro. The input cells are F23:F23. See Code Below.
> Regards
> Chris
> Sub update()
>
>
>
> Worksheets(13).Range("I20:I23").Copy
> Worksheets(13).Range("F20:23").PasteSpecial Paste:=xlPasteValues
> Application.CutCopyMode = False
>
>
>
>
> End Sub
>
|
|
0
|
|
|
|
Reply
|
Utf
|
2/26/2010 1:05:01 PM
|
|
Or...
Sub update()
With Worksheets(13)
.Unprotect Password:="Mypass"
.Range("F20:F23").Value = .Range("I20:I23").Value
.Protect Password:="Mypass"
End With
End Sub
Note to the OP. Refering to a shee by it's index number is generally
speaking a bad idea. Adding or deleelting worksheets can change that number
and then your macro will operate on the wrong sheet. Once executed there is
no undo for a macro.
--
HTH...
Jim Thomlinson
"Mike H" wrote:
> Hi,
>
> Mabe this. Note the password is case sensitive
>
> Sub update()
> With Worksheets(13)
> .Unprotect Password:="Mypass"
> .Range("I20:I23").Copy
> .Range("F20:F23").PasteSpecial Paste:=xlPasteValues
> .Protect Password:="Mypass"
> End With
> Application.CutCopyMode = False
> End Sub
> --
> Mike
>
> When competing hypotheses are otherwise equal, adopt the hypothesis that
> introduces the fewest assumptions while still sufficiently answering the
> question.
>
>
> "Chris" wrote:
>
> > Hi all
> >
> > Is there any way I can get a macro to unlock cell, paste valuse and the lock
> > again after completion. I have a macro to transfer valuse from one rang to
> > another. The macro will work ok if I leave the input cells unlocked. I would
> > like to be able to lock these cells so they can't be changed without the the
> > use of the macro. The input cells are F23:F23. See Code Below.
> > Regards
> > Chris
> > Sub update()
> >
> >
> >
> > Worksheets(13).Range("I20:I23").Copy
> > Worksheets(13).Range("F20:23").PasteSpecial Paste:=xlPasteValues
> > Application.CutCopyMode = False
> >
> >
> >
> >
> > End Sub
> >
|
|
0
|
|
|
|
Reply
|
Utf
|
2/26/2010 2:38:06 PM
|
|
Hi,
The below link has a way to achieve what you want. HTHs Rob
http://spreadsheetpage.com/index.php/tip/spreadsheet_protection_faq1/
Can I set things up so my VBA macro can make changes to Locked cells on a
protected sheet?
Yes, you can write a macro that protects the worksheet, but still allows
changes via macro code. The trick is to protect the sheet with the
UserInterfaceOnly parameter. Here's an example:
ActiveSheet.Protect UserInterfaceOnly:=True
After this statement is executed, the worksheet is protected -- but your VBA
code will still be able to make changes to locked cells and perform other
operation that are not possible on a protected worksheet.
"Chris" <Chris@discussions.microsoft.com> wrote in message
news:4CAB91EA-0A25-4FD8-8ACB-B8CE340C3BBC@microsoft.com...
> Hi all
>
> Is there any way I can get a macro to unlock cell, paste valuse and the
> lock
> again after completion. I have a macro to transfer valuse from one rang to
> another. The macro will work ok if I leave the input cells unlocked. I
> would
> like to be able to lock these cells so they can't be changed without the
> the
> use of the macro. The input cells are F23:F23. See Code Below.
> Regards
> Chris
> Sub update()
>
>
>
> Worksheets(13).Range("I20:I23").Copy
> Worksheets(13).Range("F20:23").PasteSpecial Paste:=xlPasteValues
> Application.CutCopyMode = False
>
>
>
>
> End Sub
>
|
|
0
|
|
|
|
Reply
|
Rob
|
2/26/2010 9:06:53 PM
|
|
|
3 Replies
447 Views
(page loaded in 0.057 seconds)
Similiar Articles: macro to unlock and lock cells in password protected sheet ...Hi all Is there any way I can get a macro to unlock cell, paste valuse and the lock again after completion. I have a macro to transfer valuse fro... Allow VBA code to change a locked cell?? - microsoft.public.excel ...macro to unlock and lock cells in password protected sheet ... Allow VBA code to change a locked cell?? - microsoft.public.excel ... macro to unlock and lock cells in ... Can I make a worksheet protected, locked AND not viewable ...macro to unlock and lock cells in password protected sheet ... Hi all Is there any way I can get a macro to unlock cell, paste valuse and the lock again after completion. Locked Cells - microsoft.public.excel.miscmacro to unlock and lock cells in password protected sheet ... Hi all Is there any way I can get a macro to unlock cell, paste valuse and the lock again after completion. Protect and Unprotect all worksheets with macro - microsoft.public ...macro to unlock and lock cells in password protected sheet ... Protect and Unprotect all worksheets with macro - microsoft.public ... Protect and Unprotect all worksheets ... How can I Unlock cell/worksheet? - microsoft.public.excel.misc ...macro to unlock and lock cells in password protected sheet ... Hi all Is there any way I can get a macro to unlock cell, paste ... sheet ..... can get a macro to unlock ... how to unlock a sheet without password - microsoft.public.excel ...macro to unlock and lock cells in password protected sheet ... how to brake a excel sheet passward - microsoft.public.excel ... macro to unlock and lock cells in password ... allow merging cells in protected sheet - microsoft.public.excel ...macro to unlock and lock cells in password protected sheet ... Do I have to temporarily unlock the cell ... Basic for Applications macros to ... I've tried Format/lock ... Auto-lock a cell once it's updated - microsoft.public.excel ...macro to unlock and lock cells in password protected sheet ... Auto-lock a cell once it's updated - microsoft.public.excel ... macro to unlock and lock cells in password ... Lock cells conditionally formatted in 2007 - microsoft.public ...... the same cells, go to the Home tab, Cells group, click on Format button, select Protect sheet. Type in a password ... Excel - Is it possible to lock/unlock cells using ... macro to unlock and lock cells in password protected sheet ExcelHi all Is there any way I can get a macro to unlock cell, paste valuse and the lock again after completion. I have a macro to transfer valuse from one ra macro to unlock and lock cells in password protected sheet ...Excel Discussion (Misc queries) ... Hi all Is there any way I can get a macro to unlock cell, paste valuse and the lock ... Hi, Mabe this. Note the password is case ... macro to unlock and lock cells in password protected sheet ...Hi all Is there any way I can get a macro to unlock cell, paste valuse and the lock again after completion. I have a macro to transfer valuse fro... Excel - Unlock A Password Protected Sheet - I have a file ...... password protected. What do I put in the code to unlock the sheet with the password, refresh the data, and re-lock ... has some cells password protected and I have a macro ... [Excel] A macro to unlock a password-protected sheetIt is possible to create a macro in an Excel sheet that unlock the sheet which is already protected by a password. Users can easily prepare a document in the sheet ... 7/25/2012 10:23:29 AM
|
|
|
|
|
|
|
|
|