SOLVED

Can I create a macro that runs the recorded process on newly added rows as well?

%3CLINGO-SUB%20id%3D%22lingo-sub-2665351%22%20slang%3D%22en-US%22%3ECan%20I%20create%20a%20macro%20that%20runs%20the%20recorded%20process%20on%20newly%20added%20rows%20as%20well%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2665351%22%20slang%3D%22en-US%22%3E%3CP%3EHello%2C%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI'm%20running%20a%20report%20once%20a%20week%20that%20has%20changing%20number%20of%20rows%20every%20week%20-%20same%20columns%20but%20increasing%20number%20of%20rows.%20I%20edit%20the%20report%20by%20adding%20in%20new%20columns%20with%20various%20formulas%20and%20then%20I%20use%20the%20spreadsheet%20for%20a%20Power%20BI%20report.%20As%20the%20columns%20and%20the%20formulas%20I'm%20adding%20in%20manually%20every%20week%20are%20always%20the%20same%2C%20I%20wanted%20to%20make%20the%20process%20more%20efficient%20and%20automated%2C%20hence%20I%20tried%20creating%2Frecording%20a%20macro.%20Creating%20it%20was%20easy%20and%20it%20seemed%20to%20have%20worked%2C%20until%20I%20realized%20that%20the%20macro%20only%20runs%20for%20the%20number%20of%20cells%2Frows%20that%20were%20there%20at%20the%20moment%20of%20the%20recording%20of%20the%20macro.%20Since%20my%20report%20has%20more%20rows%20every%20week%2C%20the%20macro%20is%20not%20working%20on%20these%20new%20rows%2C%20i.e.%20my%20formulas%20are%20not%20added%20in%20to%20the%20new%20rows.%20Which%20is%20mention%20in%20this%20article%3A%3C%2FP%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Fsupport.microsoft.com%2Fen-us%2Foffice%2Fautomate-tasks-with-the-macro-recorder-974ef220-f716-4e01-b015-3ea70e64937b%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3Ehttps%3A%2F%2Fsupport.microsoft.com%2Fen-us%2Foffice%2Fautomate-tasks-with-the-macro-recorder-974ef220-f716-4e01-b015-3ea70e64937b%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3EMy%20question%20is%20whether%20this%20could%20be%20changed%3F%20Is%20there%20any%20way%20to%20make%20it%20more%20dynamic%20somehow%3F%20Could%20the%20macro%20somehow%20recognize%20the%20number%20of%20rows%20in%20the%20spreadsheet%20(which%20will%20be%20different%20every%20single%20week)%20and%20add%20in%20the%20formulas%20for%20all%20the%20rows%2Fcells%20where%20there%20is%20data%3F%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EAlso%2C%20I'm%20using%20a%20PC%2C%20Windows%2010%2C%20Microsoft%20365%2C%20Excel%20version%202107%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EMany%20thanks%2C%26nbsp%3B%3C%2FP%3E%3CP%3EBo%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-2665351%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EExcel%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EFormulas%20and%20Functions%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EMacros%20and%20VBA%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2665446%22%20slang%3D%22en-US%22%3ERe%3A%20Can%20I%20create%20a%20macro%20that%20runs%20the%20recorded%20process%20on%20newly%20added%20rows%20as%20well%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2665446%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F1011577%22%20target%3D%22_blank%22%3E%40Bo_Suto%3C%2FA%3E%26nbsp%3BSince%20you%20are%20in%20to%20Power%20BI%2C%20forget%20about%20VBA%20and%20learn%20PowerQuery%20in%20stead.%20Connect%20to%20the%20weekly%20data%20files%20(Files%20from%20Folder%20will%20probably%20work%20best)%2C%20do%20some%20transformations%20and%20create%20an%20ever%20expanding%20table%20that%20feed%20your%20Power%20BI%20report.%3C%2FP%3E%3CP%3EPowerQuery%20may%20be%20a%20bit%20overwhelming%20in%20the%20beginning%2C%20but%20you'll%20love%20it%20once%20you%20get%20the%20hang%20of%20it.%3C%2FP%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Fexceloffthegrid.com%2Fpower-query-introduction%2F%22%20target%3D%22_self%22%20rel%3D%22nofollow%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Fexceloffthegrid.com%2Fpower-query-introduction%2F%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2666195%22%20slang%3D%22en-US%22%3ERe%3A%20Can%20I%20create%20a%20macro%20that%20runs%20the%20recorded%20process%20on%20newly%20added%20rows%20as%20well%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2666195%22%20slang%3D%22en-US%22%3EThanks%20a%20lot%20for%20the%20very%20useful%20link%20%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F403176%22%20target%3D%22_blank%22%3E%40Riny_van_Eekelen%3C%2FA%3E%2C%20really%20appreciate%20it.%20I've%20already%20started%20working%20my%20way%20through%20the%20different%20chapters%20%3CLI-EMOJI%20id%3D%22lia_slightly-smiling-face%22%20title%3D%22%3Aslightly_smiling_face%3A%22%3E%3C%2FLI-EMOJI%3E%3C%2FLINGO-BODY%3E
New Contributor

Hello, 

 

I'm running a report once a week that has changing number of rows every week - same columns but increasing number of rows. I edit the report by adding in new columns with various formulas and then I use the spreadsheet for a Power BI report. As the columns and the formulas I'm adding in manually every week are always the same, I wanted to make the process more efficient and automated, hence I tried creating/recording a macro. Creating it was easy and it seemed to have worked, until I realized that the macro only runs for the number of cells/rows that were there at the moment of the recording of the macro. Since my report has more rows every week, the macro is not working on these new rows, i.e. my formulas are not added in to the new rows. Which is mention in this article:

https://support.microsoft.com/en-us/office/automate-tasks-with-the-macro-recorder-974ef220-f716-4e01... 

My question is whether this could be changed? Is there any way to make it more dynamic somehow? Could the macro somehow recognize the number of rows in the spreadsheet (which will be different every single week) and add in the formulas for all the rows/cells where there is data?

 

Also, I'm using a PC, Windows 10, Microsoft 365, Excel version 2107 

 

Many thanks, 

Bo 

4 Replies

@Bo_Suto 

Yes, that is very well possible, but it'd be helpful to see the code you have now...

best response confirmed by Bo_Suto (New Contributor)
Solution

@Bo_Suto Since you are in to Power BI, forget about VBA and learn PowerQuery in stead. Connect to the weekly data files (Files from Folder will probably work best), do some transformations and create an ever expanding table that feed your Power BI report.

PowerQuery may be a bit overwhelming in the beginning, but you'll love it once you get the hang of it.

https://exceloffthegrid.com/power-query-introduction/ 

Thanks a lot for the very useful link @Riny_van_Eekelen, really appreciate it. I've already started working my way through the different chapters
Thanks for responding @Hans Vogelaar, good to know, however, I've decided to check out PowerQuery instead...