PC Review


Reply
Thread Tools Rate Thread

How to bypass cell protect message/cursor focus set

 
 
AA Arens
Guest
Posts: n/a
 
      14th May 2006
To clear everything to the right:
Range(Selection, Selection.End(xlToRight)).ClearContents

To clear the entire row:
Selection.EntireRow.ClearContents

But, surrounding the table are cells protected. When I use both of
abovement ClearContents solutions, I get a message that protected cells
cannot be modified. How to bypass this (so no modification, but also no
message).

A solution would be to have the focus automatically moved to the most
left cell of the active row, and then use Entire Row or the fixed
amount of cells to the right to be cleared.

Bart

 
Reply With Quote
 
 
 
 
Norman Jones
Guest
Posts: n/a
 
      14th May 2006
Hi Bart,

Try something like:

'=============>>
Public Sub Tester()
Dim rng1 As Range
Dim rng2 As Range

Set rng1 = Range(Selection, Selection.End(xlToRight))
Set rng1 = Intersect(rng1, Range("MyTable"))

If Not rng1 Is Nothing Then
rng1.ClearContents
End If

Set rng2 = Intersect(Selection.EntireRow, Range("MyTable"))

If Not rng2 Is Nothing Then
rng2.ClearContents
End If

End Sub
'<<=============


---
Regards,
Norman



"AA Arens" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> To clear everything to the right:
> Range(Selection, Selection.End(xlToRight)).ClearContents
>
> To clear the entire row:
> Selection.EntireRow.ClearContents
>
> But, surrounding the table are cells protected. When I use both of
> abovement ClearContents solutions, I get a message that protected cells
> cannot be modified. How to bypass this (so no modification, but also no
> message).
>
> A solution would be to have the focus automatically moved to the most
> left cell of the active row, and then use Entire Row or the fixed
> amount of cells to the right to be cleared.
>
> Bart
>



 
Reply With Quote
 
AA Arens
Guest
Posts: n/a
 
      14th May 2006
Hi Norman, your solution is great!
I also made a Clear Column-button, using xlDown and EntireColumn.

Bart

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Putting Cursor in Cell A1 of each Worksheet, then ending cursor on smalest sheet name according to VBA Editor Matt Microsoft Excel Programming 1 14th May 2007 10:21 AM
cursor focus in excel =?Utf-8?B?Zm91cnRoaG9ybg==?= Microsoft Excel Misc 1 2nd Jun 2006 07:05 AM
Focus not on cursor on opening =?Utf-8?B?UGF1bCBOZWVkaGFt?= Microsoft Word Document Management 0 14th Feb 2006 02:58 AM
cursor focus =?Utf-8?B?amVmZmhhbnZ5?= Microsoft Outlook Discussion 0 11th Apr 2005 09:58 PM
Cursor Keys does not change cell focus Skypilot Microsoft Excel Misc 3 24th Feb 2005 08:13 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 11:13 AM.