Create column from data of another column / VBA automation

may777

New Member
Joined
May 28, 2023
Messages
3
Office Version
  1. 2021
  2. 2019
  3. 2016
Platform
  1. Windows
Hi all,

So this is a report I'm exporting regularly, and what I do is create an extra column that states the "Partner Name".
(The software doesn't provide the option to just add a column of your choice)
I do this manually by creating a couple of helper columns and some IF formulas.
Also all headers must be moved one cell to the right cause they are wrong.
I'd love to have a macro to do this for me. I tried recording one but it doesn't work.
This is a trimmed down example. before and after.

ContractReceiptAETypeCharacteristicIssueDateStartingDateEndingDateClientDescriptionMoney2Money1Money3Money4Money5
3051911037397122413Nxyz 25/04/2023 02/05/2023 02/11/2023ClientNameA1,00 €1,00 €1,00 €1,00 €1,00 €
Company TotalSomeCompanyName11,00 €1,00 €1,00 €1,00 €1,00 €
Branch TotalAT11,00 €1,00 €1,00 €1,00 €1,00 €
Partner Total62PartnerNameA11,00 €1,00 €1,00 €1,00 €1,00 €
3010001037352137113Nxyz 01/05/2023[] 02/05/2023[] 02/11/2023ClientNameB1,00 €1,00 €1,00 €1,00 €1,00 €
3051571030438126513Nxyz[] 27/04/2023[] 02/05/2023[] 02/11/2023ClientNameC1,00 €1,00 €1,00 €1,00 €1,00 €
Company TotalSomeCompanyName21,00 €1,00 €1,00 €1,00 €1,00 €
Branch TotalAT21,00 €1,00 €1,00 €1,00 €1,00 €
Partner Total63PartnerNameB21,00 €1,00 €1,00 €1,00 €1,00 €
307462104211613Pxyz 28/04/2023[] 02/05/2023[] 02/08/2023ClientNameD1,00 €1,00 €1,00 €1,00 €1,00 €
Company TotalSomeCompanyName11,00 €1,00 €1,00 €1,00 €1,00 €
Branch TotalAT11,00 €1,00 €1,00 €1,00 €1,00 €
Partner Total152PartnerNameC11,00 €1,00 €1,00 €1,00 €1,00 €
3066112092174945813Nxyz[] 01/05/2023 02/05/2023[] 02/06/2023ClientNameE1,00 €1,00 €1,00 €1,00 €1,00 €
3066122092177945913Nxyz[] 01/05/2023[] 02/05/2023[] 02/08/2023ClientNameF1,00 €1,00 €1,00 €1,00 €1,00 €
Company TotalSomeCompanyName21,00 €1,00 €1,00 €1,00 €1,00 €
Branch TotalZS21,00 €1,00 €1,00 €1,00 €1,00 €
Partner Total293PartnerNameD21,00 €1,00 €1,00 €1,00 €1,00 €
Total141,00 €1,00 €1,00 €1,00 €1,00 €
XYZ Software



AFTER
(So basically if I need to do a lookup from another excel, to find that contract number 1037397 belongs to PartnerNameA, now I can)

ContractReceiptAETypeCharacteristicIssueDateStartingDateEndingDateClientDescriptionMoney2Money1Money3Money4Money5
3051911037397PartnerNameA122413Nxyz 25/04/2023 02/05/2023 02/11/2023ClientNameA1,00 €1,00 €1,00 €1,00 €1,00 €
Company TotalSomeCompanyNamePartnerNameA11,00 €1,00 €1,00 €1,00 €1,00 €
Branch TotalATPartnerNameA11,00 €1,00 €1,00 €1,00 €1,00 €
Partner Total62PartnerNameAPartnerNameA11,00 €1,00 €1,00 €1,00 €1,00 €
3010001037352PartnerNameB137113Nxyz 01/05/2023[] 02/05/2023[] 02/11/2023ClientNameB1,00 €1,00 €1,00 €1,00 €1,00 €
3051571030438PartnerNameB126513Nxyz[] 27/04/2023[] 02/05/2023[] 02/11/2023ClientNameC1,00 €1,00 €1,00 €1,00 €1,00 €
Company TotalSomeCompanyNamePartnerNameB21,00 €1,00 €1,00 €1,00 €1,00 €
Branch TotalATPartnerNameB21,00 €1,00 €1,00 €1,00 €1,00 €
Partner Total63PartnerNameBPartnerNameB21,00 €1,00 €1,00 €1,00 €1,00 €
3074621042116PartnerNameC13Pxyz 28/04/2023[] 02/05/2023[] 02/08/2023ClientNameD1,00 €1,00 €1,00 €1,00 €1,00 €
Company TotalSomeCompanyNamePartnerNameC11,00 €1,00 €1,00 €1,00 €1,00 €
Branch TotalATPartnerNameC11,00 €1,00 €1,00 €1,00 €1,00 €
Partner Total152PartnerNameCPartnerNameC11,00 €1,00 €1,00 €1,00 €1,00 €
3066112092174PartnerNameD945813Nxyz[] 01/05/2023 02/05/2023[] 02/06/2023ClientNameE1,00 €1,00 €1,00 €1,00 €1,00 €
3066122092177PartnerNameD945913Nxyz[] 01/05/2023[] 02/05/2023[] 02/08/2023ClientNameF1,00 €1,00 €1,00 €1,00 €1,00 €
Company TotalSomeCompanyNamePartnerNameD21,00 €1,00 €1,00 €1,00 €1,00 €
Branch TotalZSPartnerNameD21,00 €1,00 €1,00 €1,00 €1,00 €
Partner Total293PartnerNameDPartnerNameD21,00 €1,00 €1,00 €1,00 €1,00 €
Total141,00 €1,00 €1,00 €1,00 €1,00 €
XYZ Software


Colors are only added to help get across what I'm asking.
Thanks in advance!
 

Excel Facts

How to create a cell-sized chart?
Tiny charts, called Sparklines, were added to Excel 2010. Look for Sparklines on the Insert tab.
I think you used your Receipt Number and not your contract number in your description, but I think I understand what you are looking for generally the Partner(s) name is on the same row as the Partner Total

so if you find or look up 306611 in column A then the Partner name in Column C (before helper cells) is what you are looking for.

are you manually searching for this information or using another workbook in the same folder?
 
Upvote 0
I think you used your Receipt Number and not your contract number in your description, but I think I understand what you are looking for generally the Partner(s) name is on the same row as the Partner Total

so if you find or look up 306611 in column A then the Partner name in Column C (before helper cells) is what you are looking for.

are you manually searching for this information or using another workbook in the same folder?
No, like I said, the first table is the report that software exports. And it exports it with wrong headers. All headers must move one cell to the right.
That's what I've done to the 2nd table. (The numbers that you see in column A are some random ID of the software that I don't care about.)

In any case, the C column in the 2nd table is one I inserted and made manually, it's the end result I want. But I want to make it with VBA instead of manually.
 
Upvote 0
Ok,

I was playing around with Index(Match and Offset but I see some of the Contract numbers are 4 rows apart and some are 5.

How are you "Searching" for the contract number when you open your workbook?

CTRL+F?
 
Upvote 0
Someone sends me an excel file (call it Excel-A) with some contract numbers plus some other info like issue date, client name. It doesn't contain any Partner information (but I need to know to which Partner every contract in Excel-A it belongs)

So then I export a report from our software (table1) that does have Partner information. But as you see in table1 it only mentions the Partner after listing all his contracts. Some partner may have 1 contract, someone else might have 100.
I manually get from table1 to table2 (this is what I'm asking help about, to make it with a macro).

Then I just do a vlookup from Excel-A to the the table2 to bring the partner information into Excel-A.

I'm not looking for formulas, I'm looking for a macro/vba code to turn table1 to table2.
 
Upvote 0

Forum statistics

Threads
1,223,911
Messages
6,175,325
Members
452,635
Latest member
laura12345

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