Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
Could someone please provide me with some code to clear contents of all
unlocked cells in a worksheet? Rob |
#2
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
Try this:
Sub delunlocked() Dim aktter As Range, acell As Range Set aktter = Selection.CurrentRegion For Each acell In aktter If Not acell.Locked Then acell.ClearContents Next acell End Sub Regards, Stefi RobN ezt *rta: Could someone please provide me with some code to clear contents of all unlocked cells in a worksheet? Rob |
#3
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
Thanks Stefi,
But this comes up with a runtime error 1004. Do I need to select a range or something or will this do the whole active sheet? Rob "Stefi" wrote in message ... Try this: Sub delunlocked() Dim aktter As Range, acell As Range Set aktter = Selection.CurrentRegion For Each acell In aktter If Not acell.Locked Then acell.ClearContents Next acell End Sub Regards, Stefi "RobN" ezt rta: Could someone please provide me with some code to clear contents of all unlocked cells in a worksheet? Rob |
#4
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
You didn't post which line causes the error! Anyway try this version, it
will work on the whole active sheet: Sub delunlocked() Dim aktter As Range, acell As Range Cells.Find(What:="*", _ After:=Range("A1"), _ LookAt:=xlPart, _ LookIn:=xlValues, _ SearchOrder:=xlByRows, _ SearchDirection:=xlPrevious, _ MatchCase:=False).Activate Set aktter = Range("A1", ActiveCell) For Each acell In aktter If Not acell.Locked Then acell.ClearContents Next acell End Sub Which Excel version do you use? Stefi RobN ezt *rta: Thanks Stefi, But this comes up with a runtime error 1004. Do I need to select a range or something or will this do the whole active sheet? Rob "Stefi" wrote in message ... Try this: Sub delunlocked() Dim aktter As Range, acell As Range Set aktter = Selection.CurrentRegion For Each acell In aktter If Not acell.Locked Then acell.ClearContents Next acell End Sub Regards, Stefi "RobN" ezt *rta: Could someone please provide me with some code to clear contents of all unlocked cells in a worksheet? Rob |
#5
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
Thanks Stefi,
That worked a treat! I use vs 2007 (and 2002 for my important files, he says cynically!) BTW, what made you call one of the dims aktter? Rob "Stefi" wrote in message ... You didn't post which line causes the error! Anyway try this version, it will work on the whole active sheet: Sub delunlocked() Dim aktter As Range, acell As Range Cells.Find(What:="*", _ After:=Range("A1"), _ LookAt:=xlPart, _ LookIn:=xlValues, _ SearchOrder:=xlByRows, _ SearchDirection:=xlPrevious, _ MatchCase:=False).Activate Set aktter = Range("A1", ActiveCell) For Each acell In aktter If Not acell.Locked Then acell.ClearContents Next acell End Sub Which Excel version do you use? Stefi "RobN" ezt rta: Thanks Stefi, But this comes up with a runtime error 1004. Do I need to select a range or something or will this do the whole active sheet? Rob "Stefi" wrote in message ... Try this: Sub delunlocked() Dim aktter As Range, acell As Range Set aktter = Selection.CurrentRegion For Each acell In aktter If Not acell.Locked Then acell.ClearContents Next acell End Sub Regards, Stefi "RobN" ezt rta: Could someone please provide me with some code to clear contents of all unlocked cells in a worksheet? Rob |
#6
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
You are welcome! Thanks for the feedback!
Sorry for "aktter", I forgot that it means nothing to non-Hungarian speakers, it stands for "aktuális terület" which means currently used range. Stefi RobN ezt *rta: Thanks Stefi, That worked a treat! I use vs 2007 (and 2002 for my important files, he says cynically!) BTW, what made you call one of the dims aktter? Rob "Stefi" wrote in message ... You didn't post which line causes the error! Anyway try this version, it will work on the whole active sheet: Sub delunlocked() Dim aktter As Range, acell As Range Cells.Find(What:="*", _ After:=Range("A1"), _ LookAt:=xlPart, _ LookIn:=xlValues, _ SearchOrder:=xlByRows, _ SearchDirection:=xlPrevious, _ MatchCase:=False).Activate Set aktter = Range("A1", ActiveCell) For Each acell In aktter If Not acell.Locked Then acell.ClearContents Next acell End Sub Which Excel version do you use? Stefi "RobN" ezt *rta: Thanks Stefi, But this comes up with a runtime error 1004. Do I need to select a range or something or will this do the whole active sheet? Rob "Stefi" wrote in message ... Try this: Sub delunlocked() Dim aktter As Range, acell As Range Set aktter = Selection.CurrentRegion For Each acell In aktter If Not acell.Locked Then acell.ClearContents Next acell End Sub Regards, Stefi "RobN" ezt *rta: Could someone please provide me with some code to clear contents of all unlocked cells in a worksheet? Rob |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Delete contents in cells with macro | Excel Discussion (Misc queries) | |||
Delete contents of cells | Excel Worksheet Functions | |||
Moving from unlocked cells to unlocked cells in an excel form | Excel Worksheet Functions | |||
Delete contents of unlocked cells in another worksheet | Excel Discussion (Misc queries) | |||
How do I delete the contents of unprotected cells only? | Excel Discussion (Misc queries) |