+ Reply to Thread
Results 1 to 4 of 4

If statment to clear a range of cells

Hybrid View

  1. #1
    Registered User
    Join Date
    07-02-2008
    Location
    novato
    Posts
    29

    If statment to clear a range of cells

    I created a table that covers a range of cells (A1:G13), and I would like to make an If statement like if R10=0, (a1:g13) " ", x

    So i need a large range of cells blank I guess I could do each cell individually but I'd rather not if theres another way.

    I also have a simple function that is " =f10(which happens to be a %) & " X" and I can't seem to get excel to change the decimal into a % even thou the original is a %.

  2. #2
    Forum Guru
    Join Date
    08-05-2004
    Location
    NJ
    MS-Off Ver
    365
    Posts
    13,582
    With a Function, it's not possible in the way you are suggesting. If A1:G13 contain formulas, you can amend them with an IF statement to say
    IF(R10=0,"",Formula)
    Otherwise, you can use VBA in your spreadsheet (right click on the tab and "View Code". This code runs every time you change R10 and if it's 0, then it clears A1:G13.
    Private Sub Worksheet_Change(ByVal Target As Range)
    If Target.Row = 10 And Target.Column = 18 Then
    
    If Target.Value = 0 Then
        Range("A1:G13").ClearContents
    End If
        
    End If
    End Sub
    Do either of these options work for you?

    ChemistB

  3. #3
    Registered User
    Join Date
    07-02-2008
    Location
    novato
    Posts
    29
    Yes the second option is what I was looking for, I was also curious if I could do a similar command to "hide" those cells instead of deleting them, if this isn't possible I can live with it.

    Thanks

  4. #4
    Forum Guru
    Join Date
    08-05-2004
    Location
    NJ
    MS-Off Ver
    365
    Posts
    13,582
    You can hide rows or columns but not individual cells. You could have the code make the font color of those cells white which would effectively hide them but if they were selected, the values would appear in the formula bar.

    ChemistB

+ 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