How to link certain rows to specific headlines?

gregthenovelist

New Member
Joined
Jul 2, 2021
Messages
4
Office Version
  1. 2016
Platform
  1. MacOS
Hey Community,

I quickly skimmed through a few related articles on the forum, but I couldn't find a good answer. Maybe you can help me here!

I have transformed a pdf into an excel spreadsheet. I want to use this excel spreadsheet for some data analysis with STATA. Just that you understand what I am talking about, here is the pdf and the new excel spreadsheet:

Screenshot 2021-07-02 at 11.16.39-min.png


Screenshot 2021-07-02 at 11.08.57-min.png


To use the Excel data in STATA, I have to keep the structure of the pdf document somehow. So, I need a further section that, for instance, indicates that this is "Official Creditor" embedded in "of which interest arrears on LDOD" embedded in "short-term debt" embedded in "total debt stocks" under the category of "Albania". This is necessary so that I can compare them with a table from the year before and after.

One not very efficient option would be to introduce new columns to the left of the written part and indicate: Albania; Total Debt Stock; etc. and then merge them. This would be quite time-consuming as there are 147 countries on 10 pdfs.

Does anyone here know how I can most efficiently solve this problem? Is there potentially a "if - then" command that I could employ? How can I keep the "embeddedness" structure of the pdf in my excel spreadsheet? I would be very grateful for some ideas.

All the best,
Greg
 

Excel Facts

Move date out one month or year
Use =EDATE(A2,1) for one month later. Use EDATE(A2,12) for one year later.
Hi GregTheNovelist,

If the country entries are all the same format you could just handcraft a single non-ambiguous title template and copy and paste it into each country.

I don't know STATA but I would expect it wants key fields repeated. Maybe you could identify which are headings to be repeated and where they're needed? Something like this:

GregTheNovelist.xlsx
CDEFGHSTUVWXY
1CountryPhraseItself a sub-heading?
2USAUse of IMF credit
3AlbaniaShort-term debt
4Chileof which interest arrears on LDOD
5Albania AlbaniaAlbania1Memo: principal arrears on LDOD N
6Albania 00Disbursements
7Albania 1. SUMMARY DEBT1. SUMMARY DEBT1Principal repaymentsN
8Albania TOTAL DEBT STOCKS (EDT)TOTAL DEBT STOCKS (EDT)..1Net flows on debt N
9Albania Long-term debt (LDOD)Long-term debt (LDOD)..1Interest payments (INT) N
10Albania Public and publicly guaranteedPublic and publicly guaranteed..1Total debt service paid (TDS) N
11Albania Private nonguaranteedPrivate nonguaranteed..1TOTAL DEBT FLOWS N
12Albania Use of IMF creditUse of IMF credit0.01
13AlbaniaShort-term debt: Short-term debt: Short-term debtShort-term debt..2
14AlbaniaShort-term debt: of which interest arrears on LDODof which interest arrears on LDOD..1
15AlbaniaShort-term debt: Short-term debt: Official creditorsOfficial creditors..2
16AlbaniaShort-term debt: Short-term debt: Private creditorsPrivate creditors..2
17AlbaniaShort-term debt: Memo: principal arrears on LDODMemo: principal arrears on LDOD..1
18AlbaniaShort-term debt: Short-term debt: Official creditorsOfficial creditors..2
19AlbaniaShort-term debt: Short-term debt: Private creditorsPrivate creditors..2
20AlbaniaShort-term debt: Memo: export creditsMemo: export credits..1
21AlbaniaShort-term debt: 00
22AlbaniaShort-term debt: TOTAL DEBT FLOWSTOTAL DEBT FLOWS1
23AlbaniaShort-term debt: DisbursementsDisbursements..1
24AlbaniaShort-term debt: Short-term debt: Long-term debtLong-term debt..4
25AlbaniaShort-term debt: IMF purchasesIMF purchases0.01
26AlbaniaPrincipal repayments: Principal repaymentsPrincipal repayments..1
27AlbaniaPrincipal repayments: Principal repayments: Long-term debtLong-term debt..4
28AlbaniaPrincipal repayments: IMF repurchasesIMF repurchases0.01
29AlbaniaPrincipal repayments: Net flows on debtNet flows on debt..1
30AlbaniaPrincipal repayments: of which short-term debtof which short-term debt..1
31AlbaniaPrincipal repayments: Interest payments (INT)Interest payments (INT)..1
32AlbaniaPrincipal repayments: Principal repayments: Long-term debtLong-term debt..4
33AlbaniaPrincipal repayments: IMF chargesIMF charges0.01
34AlbaniaPrincipal repayments: Short-term debt: Principal repayments: Short-term debt: Short-term debtShort-term debt..2
35AlbaniaPrincipal repayments: Short-term debt: Net transfers on debtNet transfers on debt..1
36AlbaniaPrincipal repayments: Short-term debt: Total debt service paid (TDS)Total debt service paid (TDS)..1
37AlbaniaPrincipal repayments: Short-term debt: Principal repayments: Short-term debt: Long-term debtLong-term debt..4
38AlbaniaPrincipal repayments: Short-term debt: IMF repurchases and chargesIMF repurchases and charges0.01
39AlbaniaPrincipal repayments: Short-term debt: Short-term debt (interest only)Short-term debt (interest only)..1
BuildIt
Cell Formulas
RangeFormula
C5:C39C5=IF(ISNA(MATCH(G5,$V$2:$V$5,0)),C4,G5)
D5:D39D5=IF(ISNA(MATCH(G5,$X$2:$X$99,0)),D4&"",IF(INDEX($Y$2:$Y$9999,MATCH(G5,$X$2:$X$99,0))="N",G5&": ",D4&G5&": "))
E5:E39E5=IF(COUNTIF(G:G,G5)>1,D5&G5,G5)
S5:S39S5=COUNTIF(G:G,G5)
Named Ranges
NameRefers ToCells
_FilterDatabase=BuildIt!$G$5E5:E39, S5:S39, C5:D5
Print_Area=BuildIt!$G$4:$Q$40E5:E39, S5:S39
 
Upvote 0
This is absolutely outstanding! That is exactly what I envisioned.

Ill see whether I can replicate this.

Thanks a lot for now!

All the best
Greg
 
Upvote 0
One question @Toadstool: can I somehow save the functions to reapply them to the next country which would be in the exact same format? Or do I have to copy and past those functions for each country seperately?

Thanks a lot!
 
Upvote 0
Thanks a lot for now!
You're welcome!

One question @Toadstool: can I somehow save the functions to reapply them to the next country which would be in the exact same format? Or do I have to copy and past those functions for each country seperately?

Thanks a lot!
As I said, I don't know STATA. It's very possible it will want a new row for each number (year) so the first thing I'd do is confirm what format is needed to upload to STATA.

You don't say how you currently have the data in Excel. 147 workbooks? 147 tabs (worksheets)? 10 worksheets with multiple countries on each? It's therefore difficult to make a recommendation on how to proceed.

If you have multiple countries per worksheet but each country has exactly the same number of rows of data with the same headings then personally I would just use the Country part of the formula but handcraft the non-ambiguous headings and paste them for each country.

To get the best answer for your question I think you need to give a precise format you want for STATA (including an example and what to do about the year headings omitted from your Excel sheet) and explain how your existing Excel format for the 147 countries, preferably with some XL2BB mini-sheets or a Dropbox/Google Drive upload.



P.S. I just found a boo-boo caused by artifacts in the sheet I sourced for my test data. I've amended below:

GregTheNovelist-V2.xlsx
BCDEFGPQRSTUVW
1CountryPhraseItself a sub-heading?
2USAUse of IMF credit
3Albaniaof which interest arrears on LDODN
4ChileMemo: principal arrears on LDODN
5Albania AlbaniaAlbaniaDisbursements
6Albania 0Principal repaymentsN
7Albania 1. SUMMARY DEBT1. SUMMARY DEBTNet flows on debtN
8Albania TOTAL DEBT STOCKS (EDT)TOTAL DEBT STOCKS (EDT)..784.1Interest payments (INT)N
9Albania Long-term debt (LDOD)Long-term debt (LDOD)..659.1Total debt service paid (TDS)N
10Albania Public and publicly guaranteedPublic and publicly guaranteed..644.2TOTAL DEBT FLOWSN
11Albania Private nonguaranteedPrivate nonguaranteed..14.9
12AlbaniaUse of IMF credit: Use of IMF creditUse of IMF credit0.087.9
13AlbaniaUse of IMF credit: Use of IMF credit: Short-term debtShort-term debt..37.1
14Albaniaof which interest arrears on LDOD: of which interest arrears on LDODof which interest arrears on LDOD..3.8
15Albaniaof which interest arrears on LDOD: of which interest arrears on LDOD: Official creditorsOfficial creditors..1.0
16Albaniaof which interest arrears on LDOD: of which interest arrears on LDOD: Private creditorsPrivate creditors..2.8
17AlbaniaMemo: principal arrears on LDOD: Memo: principal arrears on LDODMemo: principal arrears on LDOD..33.4
18AlbaniaMemo: principal arrears on LDOD: Memo: principal arrears on LDOD: Official creditorsOfficial creditors..17.7
19AlbaniaMemo: principal arrears on LDOD: Memo: principal arrears on LDOD: Private creditorsPrivate creditors..15.8
20AlbaniaMemo: principal arrears on LDOD: Memo: export creditsMemo: export credits..25.9
BuildIt
Cell Formulas
RangeFormula
B5:B20B5=IF(ISNA(MATCH(F5,$T$2:$T$5,0)),B4,F5)
C5:C20C5=IF(ISNA(MATCH(F5,$V$2:$V$99,0)),C4&"",IF(INDEX($W$2:$W$9999,MATCH(F5,$V$2:$V$99,0))="N",F5&": ",C4&F5&": "))
D5:D20D5=IF(COUNTIF(F:F,F5)>1,C5&F5,F5)
Named Ranges
NameRefers ToCells
_FilterDatabase=BuildIt!$F$5D5:D20, B5:C5
 
Upvote 0
Cross-posting (posting the same question in more than one forum) is not against our rules, but the method of doing so is covered by #13 of the Forum Rules.

Be sure to follow & read the link at the end of the rule too!

Cross posted at: Connect a Heading with Subheadings
If you have posted the question at more places, please provide links to those as well.

If you do cross-post in the future and also provide links, then there shouldn’t be a problem.
 
Upvote 0

Forum statistics

Threads
1,215,731
Messages
6,126,537
Members
449,316
Latest member
sravya

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