Reference previous column - =PrevCol(Cumulative_Customers)+New_Customers

Sweedler

Board Regular
Joined
Nov 13, 2020
Messages
114
Office Version
  1. 2016
Platform
  1. Windows
  2. MacOS
Hello lovely Excellites,

So, I am working on a rather large financial document and when calculating/making prognoses I need to have some formulas that reference the previous cell (previous column in a specific row). I have a friend who did something similar and had FOR EXAMPLE:

=PrevCol(Cumulative_Customers)+New_Customers

Cumulative_Customers and New_Customers are both named ranges (and the ranges are a whole row)

The formula is meant to calculate the cumulative customers by adding the value from the previous column value of cumulative customers and add the value for New customer to that ... and so on and so on for each cell/column moving on. I assumed PrevCol was something that referred to the PREVious COLumn .. but it is not working.

I thought perhaps this could be some Macro that I am not using that he has. Any ideas out there people.
 

Excel Facts

Create a chart in one keystroke
Select the data and press Alt+F1 to insert a default chart. You can change the default chart to any chart type
It sounds like you have something like this in mind?

ABCDEFG
1
2New_Customers23571113
3
4Cumulative_Customers2510172841
Sheet1
Cell Formulas
RangeFormula
B4B4=New_Customers
C4:G4C4=prevcol(Cumulative_Customers)+New_Customers
Named Ranges
NameRefers ToCells
Cumulative_Customers=Sheet1!$4:$4C4:G4

and New_Customers:=Sheet1!$2:$2

where:
VBA Code:
Function PrevCol(RowRef As Range) As Variant

    PrevCol = RowRef(Application.Caller.Column - 1).Value

End Function

But isn't this unnecessarily convoluted when you could simply have:

C4: =B4+C2, copied to the right
 
Upvote 0
Solution
You may be right about this method being overly convoluted ... but I like the aesthetics of it.

Thank you so much for the code string, certainly did solve my issues.
 
Upvote 0

Forum statistics

Threads
1,214,653
Messages
6,120,749
Members
448,989
Latest member
mariah3

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