Results 1 to 3 of 3

Thread: VBA Macro To Clear Everything Excel Formula And Bold Text

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Member
    Join Date
    Aug 2012
    Posts
    40
    Rep Power
    0

    VBA Macro To Clear Everything Excel Formula And Bold Text

    I would like a macro to clear data on all sheets except formula, text, items in bold, values to the right of "GP % target" (the text appears in Col A and the values in Col B:M) and data that has been color filled.

    I have the following macro and have attached a sample workbook. I have also posted on Ozgrid, but the final solution I received is not working and I have not received any further reply


    Clear Data on all sheets except last 20 sheets

    In the sample data, only the first and last sheets data not to be cleared

    Your assistance in resolving this is most appreciated

    Code:
     Sub Clear_Data() 
        Dim i As Integer, r As Range 
        On Error Resume Next 
        With CreateObject("VBScript.RegExp") 
            .Pattern = "^=-?\d+(\.\d+)?([\+-/\\^\*]\d+(\.\d+)?)?$" 
            For i = 1 To Sheets.Count - 1
                For Each r In Sheets(i).UsedRange.SpecialCells(xlCellTypeFormulas) 
                    If .test(r.Formula) Then r.ClearContents 
                Next 
                For Each r In Sheets(i).UsedRange.SpecialCells(xlCellTypeConstants, 1) 
                    If Sheets(i).Cells(r.Row, 1).Value <> "GP % target" Then r.ClearContents 
                Next 
            Next 
        End With 
    End Sub

    https://www.dropbox.com/s/bodg6xsoo9...a.GP%20%25.xls
    Last edited by Flupsie; 07-03-2014 at 05:28 PM.

Similar Threads

  1. Replies: 10
    Last Post: 12-10-2012, 11:28 PM
  2. Macro To Clear Certain Data Across Many Sheets
    By Howardc in forum Excel Help
    Replies: 2
    Last Post: 12-04-2012, 09:10 AM
  3. Macro to clear data based on color fill
    By Howardc in forum Excel Help
    Replies: 7
    Last Post: 12-03-2012, 09:25 AM
  4. Excel Formula To Extract Values From Text
    By Howardc in forum Excel Help
    Replies: 1
    Last Post: 08-22-2012, 09:05 PM
  5. Need to Bold the Font of a Chart's Axes Value using VBA
    By LalitPandey87 in forum Excel Help
    Replies: 3
    Last Post: 10-06-2011, 05:18 PM

Posting Permissions

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