+ Reply to Thread
Results 1 to 3 of 3

clear cell contents if not a formula

  1. #1
    Registered User
    Join Date
    01-25-2004
    Posts
    30

    clear cell contents if not a formula

    Here i am again..
    is there any way to clear cells content only if it doesn't contain a formula?
    In other words, since I need to blamk a range in a sheet, I want also be sure that if there is a cell in the range that contains a formula, it is not blanked out...

    thanks
    *pimar

  2. #2
    Forum Expert
    Join Date
    11-23-2005
    Location
    Rome
    MS-Off Ver
    Ms Office 2016
    Posts
    1,628

    Smile Clear cell content if doesn't contain a formula

    You can do it easily with VBA (macro).

    For instance:
    myRange = "a1:e50"
    for each myCell in range(myRange)
    if not myCell.hasformula then
    myCell.clearcontents
    end if
    next

    Regards,
    Antonio

  3. #3
    Registered User
    Join Date
    01-25-2004
    Posts
    30
    Thank you Antonio...
    based on your input, what is wrong in the following :

    Set dataarange = Range("Area_Data")

    /*upperlimt and i have been already initialized
    For Each mycell In dataarange.Rows(upperlimit + i)
    MsgBox (mycell.HasFormula)
    If Not mycell.HasFormula Then
    mycell.ClearContents
    End If
    Next

    since I get an error in the MsgBox instruction , as the "mycell" is bad
    thanks
    *pimar

+ 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