+ Reply to Thread
Results 1 to 5 of 5

How to add INDIRECT to all formulas

  1. #1
    Registered User
    Join Date
    02-20-2019
    Location
    NY
    MS-Off Ver
    2016
    Posts
    4

    Question How to add INDIRECT to all formulas

    I have a workbook full of cell references and I need to add INDIRECT to all formulas. For example, I'd like the following formula...

    =Table1!E6

    ... to become ...

    =INDIRECT("Table1!E6")

    I've done this before by finding and replacing the equals sign with =INDIRECT(" and then manually pasting in ") after every formula, but my current workbook is quite large. Any suggestions would be MUCH appreciated.

    Thanks!

  2. #2
    Forum Expert mrice's Avatar
    Join Date
    06-22-2004
    Location
    Surrey, England
    MS-Off Ver
    Excel 2013
    Posts
    4,967

    Re: How to add INDIRECT to all formulas

    Try this

    Please Login or Register  to view this content.
    Martin

  3. #3
    Registered User
    Join Date
    02-20-2019
    Location
    NY
    MS-Off Ver
    2016
    Posts
    4

    Re: How to add INDIRECT to all formulas

    Thanks! That was much more efficient that what I was doing. I found some similar code to help me add the quotes and parentheses at the end but this worked all in one step!

    Now I'm trying to tackle a similar but slightly more complicate issue. I have INDIRECT in all my formulas, as needed, so now they look like this...

    =INDIRECT("Table1a!N4")

    I'd like to change all formulas in several columns so that the cells appear blank if the value in Column F (of that same row) equals 0. If values are 0 in column F, then the metrics I've included in the other columns don't apply, so I'd like the cells to be empty, rather than 0, so they are not interpreted as meaningful. So, I'd like the data set to look like this:

    Column F, Column G, Column H
    10, 8 , 9
    15, 10, 14
    0
    10, 9, 7
    0
    20, 15, 17

    So if the formula shown above was in Column H Row 3, I would want it to change to the following...

    =IF(F3=0,"",INDIRECT("Table1a!N4"))

    Is there some way I can alter the code you provided above to make this work? I tried messing with it myself but I was only able to get the extra close parentheses at the end. I'm new to VBA so this is probably well beyond my current skill level.

    Thank you again for your time and assistance!
    Last edited by jlowens25; 02-22-2019 at 11:01 AM.

  4. #4
    Registered User
    Join Date
    02-20-2019
    Location
    NY
    MS-Off Ver
    2016
    Posts
    4

    Re: How to add INDIRECT to all formulas

    I've been messing with it more and was able to get part of it figured out. The following gives me everything I want except it just looks to see if cell F999=0 for all cells replaced, rather than for that specific row

    Sub Test()
    Dim Cell As Range
    For Each Cell In Cells.SpecialCells(xlCellTypeFormulas, 23)
    Cell.Formula = "=IF(F999=0,""""," & Mid(Cell.Formula, 2, Len(Cell.Formula) - 1) & ")"
    Next Cell
    End Sub

  5. #5
    Registered User
    Join Date
    02-20-2019
    Location
    NY
    MS-Off Ver
    2016
    Posts
    4

    Re: How to add INDIRECT to all formulas

    For anyone else who may be interested, I was able to get it working...

    Sub Test()
    Dim Cell As Range
    For Each Cell In Selection
    Cell.Formula = "=IF(R[0]C6=0,""""," & Mid(Cell.Formula, 2, Len(Cell.Formula) - 1) & ")"
    Next Cell
    End Sub

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] Indirect and copying formulas
    By sknalodz in forum Excel Formulas & Functions
    Replies: 9
    Last Post: 04-03-2015, 08:07 AM
  2. [SOLVED] Fill across with formulas using INDIRECT?
    By ohnomis in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 06-13-2013, 05:57 AM
  3. [SOLVED] Indirect formulas
    By monza2 in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 10-25-2012, 10:09 PM
  4. Indirect formulas help
    By dlaidlaw in forum Excel General
    Replies: 2
    Last Post: 02-16-2011, 04:33 AM
  5. TEXT and INDIRECT formulas
    By holiday4ever in forum Excel General
    Replies: 1
    Last Post: 12-18-2010, 11:15 PM
  6. Help with Indirect formulas...
    By cpaavola in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 05-13-2009, 12:36 PM
  7. Using Named Formulas in Indirect
    By mgaworecki in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 10-27-2008, 11:41 AM

Tags for this Thread

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