+ Reply to Thread
Results 1 to 2 of 2

Look Through Sheet & Clear Cells which do not have formula

Hybrid View

  1. #1
    Forum Contributor pr4t3ek's Avatar
    Join Date
    10-13-2008
    Location
    Melbourne, Australia
    MS-Off Ver
    2003 & 2007, 2010
    Posts
    483

    Look Through Sheet & Clear Cells which do not have formula

    Hello,
    I'm looking for a script which will look through all work sheets in a workbook. Check if any of the cells contain a formula. If false, clear contents on these cells which do not contain formula. Provide message box at end showing a count of how many cells cleared.

    Cheers
    Last edited by pr4t3ek; 10-14-2009 at 12:14 AM.
    --
    Regards
    PD

    ----- Don't Forget -----

    1. Use code tags. Place "[code]" before the first line of code and "[/code"]" after the last line of code. Exclude quotation marks

    2. Thank those who have helped you by Clicking the scales above each post.

    3. Please mark your post [SOLVED] if it has been answered satisfactorily.

  2. #2
    Forum Contributor pr4t3ek's Avatar
    Join Date
    10-13-2008
    Location
    Melbourne, Australia
    MS-Off Ver
    2003 & 2007, 2010
    Posts
    483

    Re: Look Through Sheet & Clear Cells which do not have formula

    Sub ClearCellsWithFormula()
    'Sub clears the contents of a cell in your selected range if it contains a formula
        Dim myRange, wksht As String
        Dim iCount As Integer
        iCount = 0
    
        myRange = Selection.Address
        wksht = ActiveSheet.Name
      
        For Each c In Worksheets(wksht).Range(myRange).Cells
            If c.HasFormula Then
                c.ClearContents
                iCount = iCount + 1
                Application.StatusBar = iCount & " cells with Formula's have been removed"
            End If
        Next c
        MsgBox (iCount & " Cells with Formula's have been removed")
    End Sub

+ 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