VBA to (sort of) Concatenate worksheets of varying lengths - single column

JuicyHMouse

New Member
Joined
Sep 22, 2018
Messages
2
Hi all -- this is my first post here although these forums have taught me much of what I know about Excel over the years. Many late nights spent searching here, and I am very grateful. :beerchug:

However, for this project I am seeing fragments of what I need and was able to construct only partial code using my limited VBA. I hope it's ok to post hypotheticals as the work is confidential, but here is an example version of what I have:
- 1 workbook
- 3 worksheets (say, 2019!, 2020!, 2021!), not yet populated, with varying lengths/different amounts of observations​
- In all worksheets, the number of observations would be determined by the length of the same column (say, $A).​
- 1 worksheet (say, 3YRS!), with a column (say, $B) dedicated to each observation in the workbook. I.e., one row for each observation, should be contiguous and dynamic with respect to length of worksheets.​
- Column B could then populate with the name of the worksheet it references, such as "2019", or some other string unique to a worksheet.​

In case you were wondering, the rest I can take care of with formulas, and those are already written. Due to the complex nature of the actual data, a pivot table or consolidation would be insufficient for this purpose. The formula I tried to write for this exceeded the number of nested functions allowed, and I feel that even if written more efficiently it was too clunky for team usage.

Any ideas to help pretty up my messy, messy "master" sheet?

Thanks in advance, gurus!
 

Excel Facts

Using Function Arguments with nested formulas
If writing INDEX in Func. Arguments, type MATCH(. Use the mouse to click inside MATCH in the formula bar. Dialog switches to MATCH.
Welcome to the forum :smile:

:confused: I have read your explanation twce and I have no idea what your question is. Your post is a description without telling us what you want.
Are you looking for
- how to lay out the data?
- how to move the data?
- for a formula?
- a VBA solution?

Why are you adding "!" at the end of sheet names? Is it for grouping purposes?

The cloak-and-dagger stuff is getting in the way of everything. We do not care whether you are obseving bees pollinating flowers or stars in the sky. Choose something to "observe" that matches the type of data that you have and then it may be easier for you to explain.

The better the quality of the information provided by you, the more likelihood there is of arriving at a robust solution that takes account of everything
- what type of data is in each column/row of your master sheet?
- are you wanting to move that data or trying to create something for new data?
- what needs to happen to the data in the new sheets?
- it is possible that your formula can be written much more efficiently if you provide sufficient information
 
Last edited:
Upvote 0
Thanks, Yongle, for pointing that out. I guess that was conveyed badly! Sorry to anyone who viewed this and didn't know what was going on. I hope these tables help.

A VBA solution would be better for other users, as the workbook is already very formula-laden. However, if I see a good solution I will use it!

I hope the tables below provide visual context for what I'm unable to clearly express. Let me know if that clears things up!

Combined Master Sheet (WANT)
[TABLE="class: grid, width: 400"]
<tbody>[TR]
[TD="align: center"]Notes[/TD]
[TD="align: center"]Year[/TD]
[TD="align: center"]Info[/TD]
[TD="align: center"]Other[/TD]
[/TR]
[TR]
[TD]If I fill in my 2019 sheet,[/TD]
[TD]2019[/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]and it has[/TD]
[TD]2019[/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]5 observations (based on ID_num),[/TD]
[TD]2019[/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]I want the text "2020"[/TD]
[TD]2019[/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]to start to fill from the row below![/TD]
[TD]2019[/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]-------------------------------------->[/TD]
[TD]2020[/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]Same deal for 2021, [/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]whenever 2020 sheet is filled...[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
</tbody>[/TABLE]
2019 Sheet (HAVE)
[TABLE="class: grid, width: 400"]
<tbody>[TR]
[TD]1[/TD]
[TD="align: center"]ID_num[/TD]
[TD="align: center"]xx[/TD]
[TD="align: center"]yy[/TD]
[/TR]
[TR]
[TD]2[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]3[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]x[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
</tbody>[/TABLE]
2020 Sheet (HAVE)
[TABLE="class: grid, width: 400"]
<tbody>[TR]
[TD]1[/TD]
[TD="align: center"]ID_num[/TD]
[TD="align: center"]zz[/TD]
[TD="align: center"]uu[/TD]
[/TR]
[TR]
[TD]2[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]3[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]x[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
</tbody>[/TABLE]
2021 Sheet (HAVE)
[TABLE="class: grid, width: 400"]
<tbody>[TR]
[TD]1[/TD]
[TD="align: center"]ID_num[/TD]
[TD="align: center"]kk[/TD]
[TD="align: center"]mm[/TD]
[/TR]
[TR]
[TD]2[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]3[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]x[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
</tbody>[/TABLE]
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,181
Members
453,022
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