question

JonathanBrotto-3536 avatar image
0 Votes"
JonathanBrotto-3536 asked JonathanBrotto-3536 edited

Get years from raw date column and place into a row

I am simulating a report that will fetch all the dates in a master sheet. I writing in VB.net but ok in C#. Anything that can solve a part of the problem will be perfectly fine.

165207-doc-date-master-sheet.png


I want to make my new sheet with only the years in the column in the master sheet like shown below

165130-only-current-years-filter.png


dotnet-visual-basicoffice-vba-devoffice-scripts-excel-devoffice-vsto-com-dev
· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

What?
There is no question.
There is no proper explanation.
There is no proper example.
There is no correlation between the words and the illustrations.

0 Votes 0 ·

1 Answer

JoseZero-8614 avatar image
0 Votes"
JoseZero-8614 answered JoseZero-8614 edited

In Excel it is called Transpose, if you search for I guess you can find a way to filter column and collect just Years for Transpose.
In VB, if you are creating a worksheet by code, given a list of dates you can use Linq to get a distinct list of years, then use such list to fill cells one by one

 Dim myDatesList As New List(Of DateTime) From {"01/01/2023", "03/04/2017", "01/07/2017", "7/17/2018", "01/02/2019", "05/27/2019", "06/23/2020", "2/27/2021", "04/25/2021", "01/01/2022"}
 Dim myYearsSummary As List(Of Integer) = (From p In myDatesList Order By p Select p.Year).Distinct.ToList
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.