+ Reply to Thread
Results 1 to 8 of 8

Clearing Contents in a range of cells but keeping formulas.

  1. #1
    Registered User
    Join Date
    05-12-2017
    Location
    Kent, England
    MS-Off Ver
    2016
    Posts
    23

    Clearing Contents in a range of cells but keeping formulas.

    Hi Again,

    I have received excellent help on a spreadsheet so far, so much show that I showed one of my colleagues who was very impressed and said he would like to use it too, but when the contents of a cell are cleared, is it possible to leave formulas in there? i have tried adding "ButFormulas" on to the end of .ClearContents but that didn't seem to work.

    Here is a link to my original thread.

    This is the code I am currently using thanks to the help received in here earlier.

    Please Login or Register  to view this content.
    Thanks in advance

  2. #2
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    48,509

    Re: Clearing Contents in a range of cells but keeping formulas.

    Use Range.SpecialCells Method

    https://msdn.microsoft.com/en-us/lib.../ff196157.aspx

    Please Login or Register  to view this content.
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


  3. #3
    Registered User
    Join Date
    05-12-2017
    Location
    Kent, England
    MS-Off Ver
    2016
    Posts
    23

    Re: Clearing Contents in a range of cells but keeping formulas.

    Thanks! That works. Some lines (depending on the type of case) I get an error message saying

    " Run-time error '10040: No cells were found"

    It actually does exactly what I want though. Is there anyway to stop that error popping up?

  4. #4
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    48,509

    Re: Clearing Contents in a range of cells but keeping formulas.

    You're welcome. Thanks for the rep.


    Use
    Please Login or Register  to view this content.
    before and
    Please Login or Register  to view this content.
    after the ClearContents

  5. #5
    Registered User
    Join Date
    05-12-2017
    Location
    Kent, England
    MS-Off Ver
    2016
    Posts
    23

    Re: Clearing Contents in a range of cells but keeping formulas.

    Have I taken you too literally?

    Please Login or Register  to view this content.
    doesn't seem to work in this context

    Please Login or Register  to view this content.

  6. #6
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    48,509

    Re: Clearing Contents in a range of cells but keeping formulas.

    Yep.

    Please Login or Register  to view this content.

  7. #7
    Registered User
    Join Date
    05-12-2017
    Location
    Kent, England
    MS-Off Ver
    2016
    Posts
    23

    Re: Clearing Contents in a range of cells but keeping formulas.

    You are my offices hero by proxy! Thank you

  8. #8
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    48,509

    Re: Clearing Contents in a range of cells but keeping formulas.

    Thank you

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] Clearing Contents Below Merged Cells
    By snapfade in forum Excel Programming / VBA / Macros
    Replies: 16
    Last Post: 07-30-2014, 07:14 AM
  2. Clear cell contents on closing/opening without clearing formulas
    By CFT Brian in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 10-28-2013, 03:47 PM
  3. [SOLVED] Help with Code - clearing contents of cells
    By sajanpatel15 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-01-2013, 03:17 PM
  4. [SOLVED] Clearing contents of only blank cells
    By dwhite30518 in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 06-29-2012, 09:35 AM
  5. [SOLVED] [SOLVED] Excel should let me clear cell contents without clearing formulas
    By BJM in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 11-19-2005, 01:00 PM
  6. [SOLVED] clearing the contents of specified cells
    By Jimmy Pop in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 05-26-2005, 09:05 PM
  7. [SOLVED] Clearing Contents but not Formulas
    By Louise in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 01-27-2005, 01:06 PM

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