Forum Discussion
Kenechukwu_Oraelosi
Sep 20, 2022Copper Contributor
How to loop adding a column with row numbers beside each column in a dynamic range in Excel 2013
Good day. Been on this for more than a week and can't find a solution. New to VBA. I have a data sheet with multiple columns of data. I would like to add, beside each column, a column with the row n...
Kenechukwu_Oraelosi
Sep 20, 2022Copper Contributor
New here. How do i add pictures?
DexterG_III
Sep 20, 2022Iron Contributor
you should be able paste (or drag & drop as shown below) directly into these message boxes.
- Kenechukwu_OraelosiSep 20, 2022Copper ContributorHi Dexter, i finally found a way to add images, as links. Please see the edited post. Would really be grateful for your help
- DexterG_IIISep 20, 2022Iron Contributor
The quick and dirty way to accomplish this with one formula (Requires Excel 365) is:
=CHOOSECOLS(HSTACK(TRANSPOSE(MOD(SEQUENCE(3,ROWS(A1:C28),1,1)-1,ROWS($A$1:$C$28)))+1,A1:C28),{4,1,5,2,6,3})
I know there's a way to clean this up and account for the different range sizes but wanted to get something to you which was directionally correct to get you started.
- Kenechukwu_OraelosiSep 20, 2022Copper ContributorThank you for the quick response! I don't have Excel 365, i used the desktop version of Excel 2013 (old i know, its a friend's laptop while mine's undergoing repairs). Also its close. What i ultimately want to do with it is (1) in a column create a distinct list of values, then (2) beside each unique value place the sum of the rank numbers of all the times those values appear in the range. Also (3) i'll be adding columns to the sheet so the range would be dynamic, so it would need to loop through each column in the range and automatically stop at the end of the range
- Kenechukwu_OraelosiSep 20, 2022Copper ContributorI'm currently using my phone, an Android