How to add name of different sheets as a separate column field in vstack formula

questforexcel

Board Regular
Joined
Jan 18, 2019
Messages
128
Office Version
  1. 2013
Platform
  1. Windows
Hi I referred to the below article for a similar question. But was advised to post this as a new question by a notification on that thread page.

I am currently using the vstack formula to combine multiple sheets together. However, i'd like to include the name of the sheets on the vstack data.

Below is the formula I am currently using. How should I go about editing this to include the sheet name in it.

=VSTACK('Project 1'!$A$2:$X$182,'Project 2'!$A$2:$AG$756,'Project 3'!$A$2:$X$67,'Project 4'!$A$2:$X$137)

I have currently done the first step and created this formula in the name manager section. =TOCOL(TEXTAFTER(GET.WORKBOOK(1)&T(NOW()),"]"))

I was not able to understand the formula on the below link, so would appreciate if you could help me understand it. Thank you :)

What does "s" represents in this, why is there a Hstack formula being used in the Vstack formula. Thank you

=LET(s,SEQUENCE(ROWS(ShtNames)),Shts,FILTER(ShtNames,(s>=MATCH("SalaryCosts",ShtNames,0))*(s<=MATCH("TravelCosts",ShtNames,0))),FILTER(VSTACK(HSTACK(Shts,SalaryCosts:TravelCosts!B11:N10000)),VSTACK(SalaryCosts:TravelCosts!B11:B10000) <> ""))

 

Excel Facts

Do you hate GETPIVOTDATA?
Prevent GETPIVOTDATA. Select inside a PivotTable. In the Analyze tab of the ribbon, open the dropown next to Options and turn it off
How about
Excel Formula:
=LET(a,'Project 1'!$A$2:$X$182,b,'Project 2'!$A$2:$AG$756,c,'Project 3'!$A$2:$X$67,d,'Project 4'!$A$2:$X$137,VSTACK(HSTACK(EXPAND("Project 1",ROWS(a),,"Project 1"),a),HSTACK(EXPAND("Project 2",ROWS(b),,"Project 2"),b),HSTACK(EXPAND("Project 3",ROWS(c),,"Project 3"),c),HSTACK(EXPAND("Project 4",ROWS(d),,"Project 4"),d)))
 
Upvote 0
Solution
How about
Excel Formula:
=LET(a,'Project 1'!$A$2:$X$182,b,'Project 2'!$A$2:$AG$756,c,'Project 3'!$A$2:$X$67,d,'Project 4'!$A$2:$X$137,VSTACK(HSTACK(EXPAND("Project 1",ROWS(a),,"Project 1"),a),HSTACK(EXPAND("Project 2",ROWS(b),,"Project 2"),b),HSTACK(EXPAND("Project 3",ROWS(c),,"Project 3"),c),HSTACK(EXPAND("Project 4",ROWS(d),,"Project 4"),d)))
Thank you so much!! This worked for me.
Could you help me understand
At the start of the LET formula can the name be any value i'd want to assign , so it could be 1, in place of a?
What does the Hstack formula within the Vstack formula do? Does it expand the rows across the sheet?
Thank you very much!!
 
Upvote 0
You can change the variable names, but they cannot be numbers or valid cell references.
The HSTACK is the same as VSTACK but it stacks the data horizontally rather than vertically.
 
Upvote 1

Forum statistics

Threads
1,224,823
Messages
6,181,182
Members
453,020
Latest member
Mohamed Magdi Tawfiq Emam

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