+ Reply to Thread
Results 1 to 3 of 3

How to bypass cell protect message/cursor focus set

Hybrid View

  1. #1
    AA Arens
    Guest

    How to bypass cell protect message/cursor focus set

    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


  2. #2
    Norman Jones
    Guest

    Re: How to bypass cell protect message/cursor focus set

    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" <bartvandongen@gmail.com> wrote in message
    news:1147578638.587371.125990@u72g2000cwu.googlegroups.com...
    > 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
    >




  3. #3
    AA Arens
    Guest

    Re: How to bypass cell protect message/cursor focus set

    Hi Norman, your solution is great!
    I also made a Clear Column-button, using xlDown and EntireColumn.

    Bart


+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1