• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Generate a new list from the existing table

tango

Member
I have hundreds of rows that shows employees absent date and I would like to have it reformatted on a list that shows the absent date in rows per day.

I have attached the file as well. Please help and thank you in advanced.

Sample:
Person Name Blank2 Abs-Code From Blank3 Until Blank4 Type t.fr. conf. appr.
920002 Person A VAC 05-19-2026 05-20-2026 D X
920001 Person B STH 05-18-2026 05-18-2026 D X
920005 Person C VAC 05-11-2026 05-13-2026 D X
920006 Person D VAC 05-11-2026 05-15-2026 D X


Desired Result

Person Name Abs-Code From
920002 Person A VAC 05-19-2026
920002 Person A VAC 05-20-2026

920001 Person B STH 05-18-2026
920005 Person C VAC 05-11-2026
920005 Person C VAC 05-12-2026
920005 Person C VAC 05-13-2026

920006 Person D VAC 05-11-2026
 

Attachments

Last edited:
Could You use something like this?
Usage:
# Have valid data as in Your sample file.
# Press [ Do It ]-button
 

Attachments

this works. hope you dont mind to explain on how can I use or incorporate the code/macro to my working file please. You can even show the result on a new tab please.
 
Last edited:
# Open both files

# with Book1:
## select with mouse's right button Sheet1-tab
## select View Code
## activate code-sheet
## select and copy all code ( eg press Ctrl+A Ctrl+C )

# with Your working file:
## select with mouse's right button used Sheet-tab
## select View Code
## activate code-sheet
## paste code to it

# close Book1

# with Your working file:
## activate Your working files tab which has data
## select Developer from menu
## press [ Button ]
## click worksheet to create the Button
## write to Macro Name
Worksheet's name.Do_It
eg if it is Sheet1 then Sheet1.Do_It
## press [ OK ]
## You can modify button's text as You want

### Take care that You'll save file with extension .xlsb ( or .xlsm )

# usage
# Have valid data as in Your sample file.
# Press [ button ]
 
An alternative option is to employ Power Query. Here is the Mcode

Code:
let
    Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
    #"Removed Other Columns" = Table.SelectColumns(Source,{"Person", "Name", "Abs-Code", "From", "Until"}),
    #"Changed Type" = Table.TransformColumnTypes(#"Removed Other Columns",{{"From", type date}, {"Until", type date}}),
    #"Added Custom" = Table.AddColumn(#"Changed Type", "Duration", each List.Dates([From], Duration.Days([Until] -[From]) +1 ,#duration(1,0,0,0) )),
    #"Expanded Duration" = Table.ExpandListColumn(#"Added Custom", "Duration"),
    #"Removed Other Columns1" = Table.SelectColumns(#"Expanded Duration",{"Person", "Name", "Abs-Code", "Duration"})
in
    #"Removed Other Columns1


Power Query is a free AddIn for Excel 2010 and 2013, and is built-in functionality from Excel 2016 onwards (where it is referred to as "Get & Transform Data").

It is a powerful yet simple way of getting, changing and using data from a broad variety of sources, creating steps which may be easily repeated and refreshed. I strongly recommend learning how to use Power Query - it's among the most powerful functionalities of Excel.

- Follow this link to learn how to install Power Query in Excel 2010 / 2013.

- Follow this link for an introduction to Power Query functionality.

- Follow this link for a video which demonstrates how to use Power Query code provided.
 

Attachments

Back
Top