Combine data from different cells to one cell

mbrown1234

New Member
Joined
Mar 19, 2020
Messages
5
Office Version
  1. 365
Platform
  1. Windows
Hi,

I am trying to figure out how I can get from table one to table two with formulas or some easy VBA. As you can see I want to make one row for John and one for Jenny, instead for two as it is now. The date should also be combined so that the first start date and the last end date shows. E.g. 01.01.20 and 15.02.20 for John.

Johnto Canada01.01.2031.01.20
Johnto Canada01.02.2015.02.20
Jennyto US15.01.2031.01.20
Jennyto US01.02.2015.02.20

table 2
Johnto Canada01.01.2015.02.20
Jennyto US15.01.2015.02.20

Hope someone are able to help me with my problem.

Thanks
 

Excel Facts

What does custom number format of ;;; mean?
Three semi-colons will hide the value in the cell. Although most people use white font instead.
try Power Query (Get&Transform)

NameCountryDate1Date2NameCountryDate1Date2
Johnto Canada01.01.2031.01.20Johnto Canada01/01/202015/02/2020
Johnto Canada01.02.2015.02.20Jennyto US15/01/202015/02/2020
Jennyto US15.01.2031.01.20
Jennyto US01.02.2015.02.20

Rich (BB code):
let
    Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
    Type = Table.TransformColumnTypes(Source,{{"Name", type text}, {"Country", type text}, {"Date1", type date}, {"Date2", type date}}),
    Group = Table.Group(Type, {"Name", "Country"}, {{"Date1", each List.Min([Date1]), type date}, {"Date2", each List.Max([Date2]), type date}})
in
    Group
 
Upvote 0
Thanks Sandy! Perfect. Another thing,

As you can see on the picture there are now 2 more columns. The second picture shows that for John there are both x on Net and Gross and therefor red flag. Is there a way that i can collapse the table as we did in the last problem and get a red flag if the x occur on both net and gross for a person?


1584609200971.png
 
Upvote 0
sure

NameCountryDate1Date2NetGrossNameCountryDate1Date2NetGross
Johnto Canada01.01.2031.01.20xJohnto Canada01/01/202015/02/2020xx
Johnto Canada01.02.2015.02.20xJennyto US15/01/202015/02/2020x
Jennyto US15.01.2031.01.20x
Jennyto US01.02.2015.02.20x

Rich (BB code):
let
    Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
    Type = Table.TransformColumnTypes(Source,{{"Name", type text}, {"Country", type text}, {"Date1", type date}, {"Date2", type date}}),
    Group = Table.Group(Type, {"Name", "Country"}, {{"Date1", each List.Min([Date1]), type date}, {"Date2", each List.Max([Date2]), type date}, {"Count", each _, type table [Name=text, Country=text, Date1=date, Date2=date, Net=text, Gross=text]}}),
    Net = Table.TransformColumns(Table.AddColumn(Group, "Net", each List.Distinct([Count][Net])), {"Net", each Text.Combine(List.Transform(_, Text.From)), type text}),
    Gross = Table.TransformColumns(Table.AddColumn(Net, "Gross", each List.Distinct([Count][Gross])), {"Gross", each Text.Combine(List.Transform(_, Text.From)), type text})
in
    Gross

get a red flag if the x occur on both net and gross for a person
for this use Conditional Formatting because Power Query doesn't play with colours and other bells&whistles
eg. =AND(A1="x",B1="x"), suit references
 
Last edited:
Upvote 0
You are welcome
I'm glad you are happy :biggrin:
btw. it should be: =AND($A1="x",$B1="x")
 
Upvote 0

Forum statistics

Threads
1,223,952
Messages
6,175,596
Members
452,657
Latest member
giadungthienduyen

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