Loading
Ozgrid Excel Help & Best Practices Forums

Excel Video Tutorials / Excel Dashboards Reports



Results 1 to 4 of 4

Thread: Macro To Clear Cells

  1. #1
    Join Date
    25th August 2004
    Posts
    3

    Macro To Clear Cells

    I am trying to see if there can be a marco that will (for example) look in the range of cells d2:f22 and if there is a number in a cell-do nothing but if there is a non-number - clear that cell.

    Anyone know how to write this??

    thanks for any help

    Frank

    Excel Video Tutorials / Excel Dashboards Reports


  2. #2
    Join Date
    15th April 2003
    Location
    USA
    Posts
    7,387
    Welcome to the OzGrid Forum!

    Try
    VB:
    Sub DeleteStuff() 
        Dim c As Range 
        For Each c In Range("D2:F22") 
            If Not IsNumeric(c) Then c.ClearContents 
        Next c 
    End Sub 
    
    

    Excel Video Tutorials / Excel Dashboards Reports


  3. #3
    Join Date
    25th August 2004
    Posts
    3
    I can't thank you enough!
    What a huge help



    is it also possible to do the same clear from a "highlighted" thus variable section of the worksheet?

    Thanks again!!

    Excel Video Tutorials / Excel Dashboards Reports


  4. #4
    Join Date
    15th April 2003
    Location
    USA
    Posts
    7,387
    Glad to have been able to help. To change the macro so it works with a "highlighted" area of the worksheet, just replace
    Range("D2:F22")
    with
    Selection
    in the code.

    Excel Video Tutorials / Excel Dashboards Reports


Thread Information

Users Browsing this Thread

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

Possible Answers

  1. Replies: 2
    Last Post: March 30th, 2008, 19:29
  2. Clear Non-contiguous Cells
    By jgalloway in forum EXCEL HELP
    Replies: 5
    Last Post: July 24th, 2007, 15:13
  3. Clear Cells With Specified Style
    By PeteNZ in forum EXCEL HELP
    Replies: 9
    Last Post: July 6th, 2007, 13:50
  4. Clear Data Cells Only. Not Formula Cells
    By Malhar in forum EXCEL HELP
    Replies: 4
    Last Post: August 6th, 2006, 15:29
  5. Can I not clear the whole cells?
    By countryfan_nt in forum EXCEL HELP
    Replies: 2
    Last Post: July 18th, 2005, 08:54

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
  •  
porno