Changing column reference in a copied worksheet

DRFexcel

New Member
Joined
Dec 1, 2017
Messages
3
Hey guys, new here so appreciate any help.

I have worksheet A with 72 formulas that all reference the same column (but several different rows) in a different worksheet B.

Is there a way to copy worksheet A and then quickly change all the formulas so they refer to a different column in worksheet B?

To clarify--
Worksheet A's formulas all refer to cells in column C of Worksheet B. I'd like to create a copy of Worksheet A and then change all 72 formulas to refer to cells in column D of Worksheet B (same rows).

Is this possible without having to go formula by formula and manually changing the "Cs" to "Ds"?

Thanks for any tips!
 

Excel Facts

How can you turn a range sideways?
Copy the range. Select a blank cell. Right-click, Paste Special, then choose Transpose.
Try:
Code:
Sub ChangeFormulas()
    Application.ScreenUpdating = False
    Dim rng As Range
    Sheets("A").Copy after:=Sheets(Sheets.Count)
    For Each rng In ActiveSheet.Cells.SpecialCells(xlCellTypeFormulas)
        rng.Formula = Replace(rng.Formula, "C", "D")
    Next rng
    Application.ScreenUpdating = True
End Sub
 
Upvote 0
You could also try find and replace (edit: ctrl = F). No VBA needed.
Since your reference is in a different workbook, you will have a "!" preceding your "C", which will make it possible to replace all without replacing the "C"s in other places throughout the workbook. Be careful to check that it didn't replace any C's you wanted left alone though.
zXntsrD.png
 
Last edited:
Upvote 0
Ah, great idea! I just used find and replace to do one sheet, but had to skip a few formulas that contained other instances of C that I didn't want to change (and then go back and do those manually). I had not thought to combine the ! with the C.

I will try that next and see how smoothly that works, thank you!
 
Upvote 0

Forum statistics

Threads
1,215,379
Messages
6,124,605
Members
449,174
Latest member
ExcelfromGermany

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top