using VBA to copy formulas down as well as across and keeping the ranges variable.

%3CLINGO-SUB%20id%3D%22lingo-sub-2797636%22%20slang%3D%22en-US%22%3Eusing%20VBA%20to%20copy%20formulas%20down%20as%20well%20as%20across%20and%20keeping%20the%20ranges%20variable.%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2797636%22%20slang%3D%22en-US%22%3EHello%2C%20I've%20got%20a%20large%20workbook%20of%20projects%20and%20several%20lines%20of%20funding%20for%20each%20project.%20at%20the%20base%20of%20each%20chunk%20of%20said%20project's%20funding%20there%20is%20a%20sum%20total.%20I'm%20wondering%20if%20it's%20possible%20to%20then%20drag%20each%20of%20those%20sum%20total%20formulas%20across%20the%203%20columns%20to%20the%20right%20so%20that%20right%20next%20to%20the%20funding%20totals%20I%20can%20also%20total%20up%20some%20other%20datapoints.%20each%20project%20has%20different%20amounts%20of%20funding%20lines%20and%20so%20I%20need%20the%20formula%20to%20be%20smart%20enough%20to%20detect%20the%20sum%20totals%20to%20drag%20across%20and%20to%20apply%20this%20down%20the%20entire%20sheet%20of%20data.%20Is%20this%20possible%20and%20how%20can%20I%20achieve%20this%3F%3CBR%20%2F%3EThank%20you%20in%20advance%20for%20all%20your%20help!%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-2797636%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EExcel%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EMacros%20and%20VBA%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2797693%22%20slang%3D%22en-US%22%3ERe%3A%20using%20VBA%20to%20copy%20formulas%20down%20as%20well%20as%20across%20and%20keeping%20the%20ranges%20variable.%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2797693%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F1170756%22%20target%3D%22_blank%22%3E%40sbast22%3C%2FA%3E%26nbsp%3BI%20may%20not%20have%20a%20clear%20picture%20in%20my%20mind%20of%20what%20you%20are%20dealing%20with%2C%20but%20is%20seems%20unwise%20to%20maintain%20a%20large%20list%20of%20funding%20information%20and%20then%20insert%20totals%20by%20project%20in%20the%20same%20list.%20Better%20to%20summarise%20the%20%22funding%20data%20base%22%20in%20a%20pivot%20table.%3C%2FP%3E%3C%2FLINGO-BODY%3E
New Contributor
Hello, I've got a large workbook of projects and several lines of funding for each project. at the base of each chunk of said project's funding there is a sum total. I'm wondering if it's possible to then drag each of those sum total formulas across the 3 columns to the right so that right next to the funding totals I can also total up some other datapoints. each project has different amounts of funding lines and so I need the formula to be smart enough to detect the sum totals to drag across and to apply this down the entire sheet of data. Is this possible and how can I achieve this?
Thank you in advance for all your help!
6 Replies

@sbast22 I may not have a clear picture in my mind of what you are dealing with, but is seems unwise to maintain a large list of funding information and then insert totals by project in the same list. Better to summarise the "funding data base" in a pivot table.

let's say that the totals to the right of each funding line is what's being billed against said project for billing period 1 ... then billing period 2 and so on. If I cannot figure out a way to sum across using vba then i have to manually do it to learn for each new billing period what the total billed will be. then verify that against my invoice.

@sbast22 Can you upload a file with some made-up data for three or four projects and visualise what you want to achieve.

@Riny_van_Eekelen Please see file attached. This is much smaller scale as I mainly need to give a visual for how this works. Previously, we had to hand jam each total to be invoiced. But with this workbook I built we can use vlookup to line up the billing totals. The issue is that we get funding as we go and so the lines will change. Typically what I do is copy S4 & T4 all the way down Then copy columns S over to column R as Values Only. From there, I basically drag the sum total formula across to column T. When doing this I also copy the blank cells in between because the spacing is basically the same in the workbook that I will then paste column R into once i've ensured that the bill looks accurate. I hope that's not too confusing :-/.

@sbast22 I took the liberty to restructure you data a bit, so that I could create a pivot table. See attached.

 

Though, I realise that it has totally messed up your lookups, the point I would like to make is that you should not format raw data with merged cells, double header rows and empty columns. Keep it clean, so that you use pivot tables to the summarising for your.

 

But then again, perhaps I totally misunderstand your needs. Then I can only apologise for having taken your time.

I appreciate the attempt. Although what I am trying to do is not about visualization for anyone. This is a billing process for a very large contract and it takes up a lot of time having to do repetitive copying and pasting and formatting (the dragging formulas). I was trying to build a macros to help with speeding up that portion while keeping the rows variable since the # of funding lines a project would have are not always the same.