Move the range to the right

StuartM1

Board Regular
Joined
Oct 6, 2010
Messages
111
Hi all,

Hope everyone's enjoying their Holidays.

Please help. I inherited a spreadsheet with formulas that refer to a separate range. With each new month, the entire range needs to move over one column to consider only the latest (12 mo) periods.

Is there a quick and easy way to change the cell references inside the formulas from, for example,

A2:C50 to B2:D50

Thanks very much!!
 
Last edited:

Excel Facts

Select a hidden cell
Somehide hide payroll data in column G? Press F5. Type G1. Enter. Look in formula bar while you arrow down through G.
Higlight the range of formula cells>>Copy >>Select the first new cell >>Paste
OR
Highlight the formula cells>>>grab the little black box in the bottom right of the last cell>> drag one cell to the right
 
Last edited:
Upvote 0
You can... but I wouldn't recommend doing this.

Instead, why not use something like =OFFSET(A2,0,A1,49,12) where A1 has the month number? That way, if you ever want to go back to the previous month, you'd just change A1's value.

That said, you can get the explicit answer to your question with code like this that uses .offset and .directprecedents together.

Code:
Sub test()

Dim my_cell

For Each my_cell In Selection

    With my_cell

        .Formula = Replace(.Formula, .DirectPrecedents.Address(0, 0), .DirectPrecedents.Offset(0, 1).Address(0, 0))

    End With

Next my_cell

End Sub
 
Last edited:
Upvote 0

Forum statistics

Threads
1,214,945
Messages
6,122,397
Members
449,081
Latest member
JAMES KECULAH

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