+ Reply to Thread
Results 1 to 4 of 4

Change Links to avoid 0 Values showing

Hybrid View

  1. #1
    Valued Forum Contributor realniceguy5000's Avatar
    Join Date
    03-20-2008
    Location
    Fl
    MS-Off Ver
    Excel 2003 & 2010
    Posts
    951

    Change Links to avoid 0 Values showing

    Hi, I have a ton of links to other worksheets that since no information is in the orginal cell the results come up as a zero value on the new sheet.

    I really cant hide all the zeros in the options as some zero values I need to show but they are a much smaller number so it would be easier just to change all the current links.

    What kind of script could I use to edit the current link to include the current link and add a if then statement to the formula.
    Here is an example:
    From:
    ='1st Shift'!C15
    To:
    =If('1st Shift'!C15 ="","",'1st Shift'!C15)
    Thank You, Mike
    Last edited by realniceguy5000; 07-08-2011 at 03:43 PM.

  2. #2
    Valued Forum Contributor realniceguy5000's Avatar
    Join Date
    03-20-2008
    Location
    Fl
    MS-Off Ver
    Excel 2003 & 2010
    Posts
    951

    Re: Change Links to avoid 0 Values showing

    Here what I came up with should anyone need it.

    Sub Zero()
    Dim myStr As String
    Dim Cel As Range
    For Each Cel In Selection
    If Cel.HasFormula = True Then
    If Not Cel.Formula Like "=IF(ISERROR*" Then
    myStr = Right(Cel.Formula, Len(Cel.Formula) - 1)
    Cel.Value = "=If(" & myStr & "="""",""""," & myStr & ")"
    End If
    End If
    Next
    End Sub
    And this one below with hide div/0 errors

    Sub DIV0() 
    Dim myStr As String
    Dim Cel As Range
    For Each Cel In Selection
    If Cel.HasFormula = True Then
    If Not Cel.Formula Like "=IF(ISERROR*" Then
    myStr = Right(Cel.Formula, Len(Cel.Formula) - 1)
    Cel.Value = "=IF(ISERROR(" & myStr & "),""""," & myStr & ")"
    End If
    End If
    Next
    End Sub
    ...
    Thank You, Mike

    Some Helpful Hints:

    1. New members please read & follow the Forum Rules
    2. Use Code Tags...Place[code]Before the first line and[/code] After the last line.
    3. If you are pleased with a solution mark your post SOLVED.
    4. Thank those who have help you by clicking the scales at the top right of the post.

    Here...

  3. #3
    Forum Expert snb's Avatar
    Join Date
    05-09-2010
    Location
    VBA
    MS-Off Ver
    Redhat
    Posts
    5,649

    Re: Change Links to avoid 0 Values showing

    I'd prefer
    Sub snb()
      For Each sh In Sheets
        For Each cl In sh.Cells.SpecialCells(xlCellTypeFormulas)
          If Evaluate("isref(" & Mid(cl.Formula, 2) & ")") Then cl.Formula = Replace(Replace("=IF(#=~~,~~,#)", "~", Chr(34)), "#", Mid(cl.Formula, 2))
        Next
      Next
    End Sub



  4. #4
    Valued Forum Contributor realniceguy5000's Avatar
    Join Date
    03-20-2008
    Location
    Fl
    MS-Off Ver
    Excel 2003 & 2010
    Posts
    951

    Re: Change Links to avoid 0 Values showing

    I have to agree with you on that... Nice Work...

    .

+ 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