Update formulas by 1 row

westcoastrhiann

New Member
Joined
Apr 21, 2014
Messages
7
I would like to write a macro that I can run once a week to update certain cell formulas by 1 row. I'm thinking maybe offset but can't quite wrap my head around it.

Here's what I need

So in week 1 my spreadsheet would look something like this:

ABC
15=A1+1
210=A2+2
315=A3+3
420=A4+4
525=A5+5

<tbody>
</tbody>

After I run the macro in Week 1 the formulas would be:


A
BC
15=A2+1
210=A3+2
315=A4+3
420=A5+4
525=A6+5


<tbody>
</tbody>

After I run the macro in Week 2 the formulas would be:


A
BC
15=A3+1
210=A4+2
315=A5+3
420=A6+4
525=A7+5


<tbody>
</tbody>

What is the easiest way to update the cell row reference by 1?

Thanks!
 

Excel Facts

Workdays for a market open Mon, Wed, Friday?
Yes! Use "0101011" for the weekend argument in NETWORKDAYS.INTL or WORKDAY.INTL. The 7 digits start on Monday. 1 means it is a weekend.
Maybe stored the "jump" in some other cell, and increase the single cell by 1 each week.
So, let's say that the cell is M1.
We start out with this formula:
Code:
=OFFSET(A1,$M$1,0)+1
and copy down for all rows.
The initial value in M1 is 0.

Each week, we up the value in M1 (i.e. 1, then 2 the following week, etc) to make our formulas jump down one row.
 
Upvote 0
Sure, but it really isn't any shorter/faster.
Instead of updating a single cell, you would need to select a macro to run.
So, it won't really save you any time.

If you want to go the VBA route, please let us know the following:
- Is this always going to be the formulas in column B?
- Will they be starting on row 1 or row 2?
- Will it always just be updating the current formulas (not adding or removing anything)?
 
Upvote 0
If you really want a VBA solution, there are many ways to go about it. Here is one:
Code:
Sub MyIncrementer()

    Dim r As Long, lr As Long
    Dim frm As String, newFrm As String
    Dim fArray() As String
    Dim part1 As Long, part2 As Long
    
    Application.ScreenUpdating = False
    
'   Find last row with data in column C
    lr = Cells(Rows.Count, "C").End(xlUp).Row
    
'   Loop through all rows, starting with row 1
    For r = 1 To lr
'       Get formula of column C current row
        frm = Mid(Cells(r, "C").Formula, 2)
'       Split at plus sign
        fArray = Split(frm, "+")
'       Get different parts of formula, and add one to row number
        part1 = Mid(fArray(0), 2) + 1
        part2 = fArray(1)
'       Rebuild new formula
        newFrm = "=A" & part1 & "+" & part2
'       Apply new formula to column C in current row
        Cells(r, "C").Formula = newFrm
    Next r
    
    Application.ScreenUpdating = True
    
    MsgBox "Process complete!"
    
End Sub
 
Last edited:
Upvote 0

Forum statistics

Threads
1,214,832
Messages
6,121,849
Members
449,051
Latest member
excelquestion515

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