Results 1 to 9 of 9
  1. #1
    2 Star Lounger
    Join Date
    Feb 2001
    Location
    Appleton, Wisconsin, USA
    Posts
    188
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Is there a way to run an Edit, Replace on a column of cells that will allow each formula to refer to the cell next to it (as in "E1, E2, E3, E4..." based on what cell I'm in rather than an absolute reference to, say "E4")?

    I can't do the "drag-down" method of formula duplication because each formula has an external link in it.

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts
    I don't understand - each formula has an external link *and* you want it to refer to the "cell next to it"?
    Can you try to explain more clearly?

  3. #3
    2 Star Lounger
    Join Date
    Feb 2001
    Location
    Appleton, Wisconsin, USA
    Posts
    188
    Thanks
    0
    Thanked 0 Times in 0 Posts
    [quote name='HansV' post='783264' date='06-Jul-2009 16:18']I don't understand - each formula has an external link *and* you want it to refer to the "cell next to it"?
    Can you try to explain more clearly?[/quote]

    yes: the formulas refer to various worksheets, but I want to do an index lookup of a value that I enter in the column next to my cell (rather than something static).

    I can do the replace cell by cell, but there are over 250 rows of formulas - time consuming AND error prone!

    Does that make it clearer?

  4. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts
    Can you provide a more detailed description?

  5. #5
    2 Star Lounger
    Join Date
    Feb 2001
    Location
    Appleton, Wisconsin, USA
    Posts
    188
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Unhappy

    [quote name='HansV' post='783272' date='06-Jul-2009 16:50']Can you provide a more detailed description?[/quote]

    This should be close enough for what I'm trying to do:

    Let's say you wanted to replace the second "UTI Protocol" in the first column's formula with whatever value was in the second column, rather than with an explicit reference. Is there a way to do this?

    (note that I can't "drag down" the formula because other pieces of the formula are individually set)

    THANK YOU for being willing to spend time on this little monster...
    Attached Files Attached Files

  6. #6
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts
    Would this do what you want?

    =IF("UTI Protocol"=B1,1,0)

  7. #7
    2 Star Lounger
    Join Date
    Feb 2001
    Location
    Appleton, Wisconsin, USA
    Posts
    188
    Thanks
    0
    Thanked 0 Times in 0 Posts
    [quote name='HansV' post='783277' date='06-Jul-2009 17:23']Would this do what you want?

    =IF("UTI Protocol"=B1,1,0)[/quote]


    YES - but how do I get the "B1" in there without manually updating each formula? I love Excel's Replace function - guess I'm just wanting more from it than it can deliver...

  8. #8
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts
    I don't think Edit | Replace can do this. You could run the following macro:

    Code:
    Sub FixFormulas()
      Dim oCell As Range
      Dim strFormula As String
      Dim intPos1 As Integer
      Dim intPos2 As Integer
      For Each oCell In Selection
    	strFormula = oCell.Formula
    	intPos1 = InStr(strFormula, "=""")
    	If intPos1 > 0 Then
    	  intPos2 = InStr(intPos1 + 2, strFormula, """,")
    	  If intPos2 > 0 Then
    		strFormula = Left(strFormula, intPos1) & _
    		  oCell.Offset(0, 1).Address(False, False) & _
    		  Mid(strFormula, intPos2 + 1)
    		oCell.Formula = strFormula
    	  End If
    	End If
      Next oCell
    End Sub
    You need to select the cells with the formulas that you want to change before you run the macro.

    Always test on a copy of your workbook!

  9. #9
    WS Lounge VIP rory's Avatar
    Join Date
    Dec 2000
    Location
    Burwash, East Sussex, United Kingdom
    Posts
    6,280
    Thanks
    3
    Thanked 191 Times in 177 Posts
    You could switch to R1C1 reference style temporarily (Tools-Options, General tab), replace ="UTI Protocol" with =RC[1] and then switch back to A1 style.
    Regards,
    Rory

    Microsoft MVP - Excel

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •