+ Reply to Thread
Results 1 to 3 of 3

VBA code to clear the contents (or value) of a cell without clearing the formula

  1. #1
    Registered User
    Join Date
    02-01-2013
    Location
    Australia
    MS-Off Ver
    Excel 2007
    Posts
    16

    VBA code to clear the contents (or value) of a cell without clearing the formula

    I have a formula in one cell (say P4) that displays a date (in dd/mm/yy hh:mm:ss format) based on the value in another cell

    In my VBA code I initialise P4 with .ClearContents which clears the cell
    BUT takes out the formula

    Can anybody help with the correct syntax in VBA to leave the formula intact

    Thanks in advance

    BazzaBit

  2. #2
    Forum Expert Moo the Dog's Avatar
    Join Date
    09-28-2012
    Location
    Wisconsin
    MS-Off Ver
    Office 365 (PC & Mac)
    Posts
    1,845

    Re: VBA code to clear the contents (or value) of a cell without clearing the formula

    I am not sure that you can clear just the displayed value. What I would do is replace the formula back into the cell AFTER the line with .ClearContents. Just my 2 cents.

    - Moo

  3. #3
    Forum Expert
    Join Date
    12-14-2012
    Location
    London England
    MS-Off Ver
    MS 365 Office Suite.
    Posts
    8,448

    Re: VBA code to clear the contents (or value) of a cell without clearing the formula

    The only way I can think of is to change the font colour. so the contents of the cell are hidden.

    but you are better of modifying the code something like

    Please Login or Register  to view this content.

+ 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