+ Reply to Thread
Results 1 to 6 of 6

How can I restrict my macro to a range of unlocked cells rather than the whole sheet?

  1. #1
    Registered User
    Join Date
    05-29-2012
    Location
    San Diego, CA USA
    MS-Off Ver
    Excel 2010
    Posts
    11

    How can I restrict my macro to a range of unlocked cells rather than the whole sheet?

    I've got a form that mayy be used several times throughout a user's day. Each time it is filled out and saved or sent, it will need to be cleared. I've got a macro to clear the form by changing all unprotected cells to a null value. Trouble is, I would like to omit just one cell from all of that. The cell is unprotected but it's a drop down and I want it to default to a value. Can the following code be restricted by column or print area? (The cell I want to avoid is outside the print area or if by column, I'd like to clear all unprotected cells up to but not past column 'AM')

    Please Login or Register  to view this content.
    Thanks for the help

  2. #2
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: How can I restrict my macro to a range of unlocked cells rather than the whole sheet?

    Instead of UsedRange, selct all the cells to be deleted & create a Named Range which excludes the cell you want to keep. Use that named range in the macro
    Hope that helps.

    RoyUK
    --------
    For Excel Tips & Solutions, free examples and tutorials why not check out my web site

    Free DataBaseForm example

  3. #3
    Forum Expert Ace_XL's Avatar
    Join Date
    06-04-2012
    Location
    UAE
    MS-Off Ver
    2016
    Posts
    6,074

    Re: How can I restrict my macro to a range of unlocked cells rather than the whole sheet?

    Instead of not clearing this umprotected cell (say AP10), why dont you re-type the 'default' value. An adaptation of the below..

    Please Login or Register  to view this content.
    Life's a spreadsheet, Excel!
    Say thanks, Click *

  4. #4
    Registered User
    Join Date
    05-29-2012
    Location
    San Diego, CA USA
    MS-Off Ver
    Excel 2010
    Posts
    11

    Re: How can I restrict my macro to a range of unlocked cells rather than the whole sheet?

    Thank you both for replying.

    Roy - I tried that but it seems that since I have merged cells it won't let me define a range consisting of all of these unprotected cells. It will but win it goes to clear them it wants to look at only the first cell of each and not the merged collection, which causes an error.

    Ace - The concept is perfect. So, if I understand correctly, this would reset the cell I want to preserve to its default. Where would I designate its default though? (Its a drop down list and the value I would like to 'default' is the first of three values in a list.

    Thanks again to both of you.

  5. #5
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: How can I restrict my macro to a range of unlocked cells rather than the whole sheet?

    Always avoid using MergedCells, use Center across selection.

  6. #6
    Forum Expert Ace_XL's Avatar
    Join Date
    06-04-2012
    Location
    UAE
    MS-Off Ver
    2016
    Posts
    6,074

    Re: How can I restrict my macro to a range of unlocked cells rather than the whole sheet?

    Substitute in post #3

    Please Login or Register  to view this content.
    with
    Please Login or Register  to view this content.
    assuming your drop-down list options are listed in Cells X1,X2,X3

+ 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