VBA Append data based on headers

%3CLINGO-SUB%20id%3D%22lingo-sub-2619995%22%20slang%3D%22en-US%22%3EVBA%20Append%20data%20based%20on%20headers%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2619995%22%20slang%3D%22en-US%22%3E%3CP%3Egood%20day%2C%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3Ecan%20anyone%20help%20me%20with%20this%3F%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20want%20to%20append%20data%20based%20on%20headers%20not%20with%20cell%20address%20or%20column%20number.%3C%2FP%3E%3CP%3EPlease%20see%20the%20example%20below.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20want%20to%20run%20this%20through%20macro%20as%20well.%20Can%20anyone%20give%20me%20a%20script%3F%20Please.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3Ethank%20you!%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3Esource%20file%3C%2FP%3E%3CTABLE%20width%3D%221080%22%3E%3CTBODY%3E%3CTR%3E%3CTD%20width%3D%2264%22%3Edoc%20num%3C%2FTD%3E%3CTD%20width%3D%22146%22%3EDependent%20Name%20Last%3C%2FTD%3E%3CTD%20width%3D%22150%22%3EDependent%20Name%20First%3C%2FTD%3E%3CTD%20width%3D%2264%22%3Edoc%20num%3C%2FTD%3E%3CTD%20width%3D%22146%22%3EDependent%20Name%20Last%3C%2FTD%3E%3CTD%20width%3D%22150%22%3EDependent%20Name%20First%3C%2FTD%3E%3CTD%20width%3D%2264%22%3Edoc%20num%3C%2FTD%3E%3CTD%20width%3D%22146%22%3EDependent%20Name%20Last%3C%2FTD%3E%3CTD%20width%3D%22150%22%3EDependent%20Name%20First%3C%2FTD%3E%3C%2FTR%3E%3CTR%3E%3CTD%3E1%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3B%3C%2FTD%3E%3CTD%3E%26nbsp%3B%3C%2FTD%3E%3CTD%3E5%3C%2FTD%3E%3CTD%3E%26nbsp%3B%3C%2FTD%3E%3CTD%3E%26nbsp%3B%3C%2FTD%3E%3C%2FTR%3E%3C%2FTBODY%3E%3C%2FTABLE%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3Edesired%20result%3C%2FP%3E%3CTABLE%20width%3D%22356%22%3E%3CTBODY%3E%3CTR%3E%3CTD%20width%3D%2260%22%3Edoc%20num%3C%2FTD%3E%3CTD%20width%3D%22146%22%3EDependent%20Name%20Last%3C%2FTD%3E%3CTD%20width%3D%22150%22%3EDependent%20Name%20First%3C%2FTD%3E%3C%2FTR%3E%3CTR%3E%3CTD%3E1%3C%2FTD%3E%3CTD%3Eads%3C%2FTD%3E%3CTD%3E123%3C%2FTD%3E%3C%2FTR%3E%3CTR%3E%3CTD%3E2%3C%2FTD%3E%3CTD%3E%26nbsp%3B%3C%2FTD%3E%3CTD%3E%26nbsp%3B%3C%2FTD%3E%3C%2FTR%3E%3CTR%3E%3CTD%3E3%3C%2FTD%3E%3CTD%3Eqwe231%3C%2FTD%3E%3CTD%3E121fsd%3C%2FTD%3E%3C%2FTR%3E%3CTR%3E%3CTD%3E4%3C%2FTD%3E%3CTD%3E%26nbsp%3B%3C%2FTD%3E%3CTD%3E%26nbsp%3B%3C%2FTD%3E%3C%2FTR%3E%3CTR%3E%3CTD%3E5%3C%2FTD%3E%3CTD%3Eqwe12dasd2%3C%2FTD%3E%3CTD%3E12312dasd2%3C%2FTD%3E%3C%2FTR%3E%3CTR%3E%3CTD%3E1%3C%2FTD%3E%3CTD%3E%26nbsp%3B%3C%2FTD%3E%3CTD%3E%26nbsp%3B%3C%2FTD%3E%3C%2FTR%3E%3CTR%3E%3CTD%3E2%3C%2FTD%3E%3CTD%3Easd%3C%2FTD%3E%3CTD%3Easd231%3C%2FTD%3E%3C%2FTR%3E%3CTR%3E%3CTD%3E3%3C%2FTD%3E%3CTD%3Eaa231a%3C%2FTD%3E%3CTD%3Ewd1eqw131%3C%2FTD%3E%3C%2FTR%3E%3CTR%3E%3CTD%3E4%3C%2FTD%3E%3CTD%3E%26nbsp%3B%3C%2FTD%3E%3CTD%3E%26nbsp%3B%3C%2FTD%3E%3C%2FTR%3E%3CTR%3E%3CTD%3E5%3C%2FTD%3E%3CTD%3E%26nbsp%3B%3C%2FTD%3E%3CTD%3E%26nbsp%3B%3C%2FTD%3E%3C%2FTR%3E%3CTR%3E%3CTD%3E1%3C%2FTD%3E%3CTD%3Easd231%3C%2FTD%3E%3CTD%3E12315sfasd%3C%2FTD%3E%3C%2FTR%3E%3CTR%3E%3CTD%3E2%3C%2FTD%3E%3CTD%3E%26nbsp%3B%3C%2FTD%3E%3CTD%3E%26nbsp%3B%3C%2FTD%3E%3C%2FTR%3E%3CTR%3E%3CTD%3E3%3C%2FTD%3E%3CTD%3Eascas1231ds%3C%2FTD%3E%3CTD%3Excqweqdw2%3C%2FTD%3E%3C%2FTR%3E%3CTR%3E%3CTD%3E4%3C%2FTD%3E%3CTD%3E123dqwdas%3C%2FTD%3E%3CTD%3Easca212e1%3C%2FTD%3E%3C%2FTR%3E%3CTR%3E%3CTD%3E5%3C%2FTD%3E%3CTD%3E%26nbsp%3B%3C%2FTD%3E%3CTD%3E%26nbsp%3B%3C%2FTD%3E%3C%2FTR%3E%3C%2FTBODY%3E%3C%2FTABLE%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2633966%22%20slang%3D%22en-US%22%3ERE%3A%20VBA%20Append%20data%20based%20on%20headers%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2633966%22%20slang%3D%22en-US%22%3EThis%20forum%20is%20for%20support%20for%20Microsoft%20Learn%20and%20Microsoft%20training.%20Try%20another%20community%20%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2FCommunities%2Fct-p%2Fcommunities%22%20target%3D%22_blank%22%3Ehttps%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2FCommunities%2Fct-p%2Fcommunities%3C%2FA%3E%3C%2FLINGO-BODY%3E
Occasional Contributor

good day,

 

can anyone help me with this?

 

I want to append data based on headers not with cell address or column number.

Please see the example below.

 

I want to run this through macro as well. Can anyone give me a script? Please.

 

thank you!

 

 

 

source file

doc numDependent Name LastDependent Name Firstdoc numDependent Name LastDependent Name Firstdoc numDependent Name LastDependent Name First
1ads1231  1asd23112315sfasd
2  2asdasd2312  
3qwe231121fsd3aa231awd1eqw1313ascas1231dsxcqweqdw2
4  4  4123dqwdasasca212e1
5qwe12dasd212312dasd25  5  

 

 

desired result

doc numDependent Name LastDependent Name First
1ads123
2  
3qwe231121fsd
4  
5qwe12dasd212312dasd2
1  
2asdasd231
3aa231awd1eqw131
4  
5  
1asd23112315sfasd
2  
3ascas1231dsxcqweqdw2
4123dqwdasasca212e1
5  

 

0 Replies