Jaymond Flurrie
Well-known Member
- Joined
- Sep 22, 2008
- Messages
- 919
- Office Version
- 365
- Platform
- Windows
Does someone here have a ready code (formula or VBA) that would share data from a column to several columns.
So what I'm _not_ looking for is a "Text to columns" functionality, I know how to use that.
What I'm looking for is that when I import data from a website (like bank statement), it shows up like this:
5.10.2021
Food from store
-23,78
5.10.2021
Electricity bill
-15,15
3.10.2021
Food from store
-16
and that's in exactly one column. I want to split that to three columns, so that it turns out like this:
5.10.2021 Food from store -23,78
5.10.2021 Electricity bill -15,15
3.10.2021 Food from store -16
So every third row is a date, every third row is a description and every third row is an amount.
So a more generic definition: Split data in a column into X columns
I'm sure there's ready made code for this, I just don't know what to search with in order to avoid the "use text to columns functionality"-answers.
Here's a start for it:
Assuming the data is in Column A, starting from row 1, to Column B formula to get the first column values:
=IF(MOD(ROW(A1)+2;3)=0;A1;"")
to Column C to get the second column values:
=IF(MOD(ROW(A1)+1;3)=0;A1;"")
and to Column D to get the third column values:
=IF(MOD(ROW(A1);3)=0;A1;"")
but this returns values to every row, with two of the columns being empty. So this is not ready, although it is a start.
So what I'm _not_ looking for is a "Text to columns" functionality, I know how to use that.
What I'm looking for is that when I import data from a website (like bank statement), it shows up like this:
5.10.2021
Food from store
-23,78
5.10.2021
Electricity bill
-15,15
3.10.2021
Food from store
-16
and that's in exactly one column. I want to split that to three columns, so that it turns out like this:
5.10.2021 Food from store -23,78
5.10.2021 Electricity bill -15,15
3.10.2021 Food from store -16
So every third row is a date, every third row is a description and every third row is an amount.
So a more generic definition: Split data in a column into X columns
I'm sure there's ready made code for this, I just don't know what to search with in order to avoid the "use text to columns functionality"-answers.
Here's a start for it:
Assuming the data is in Column A, starting from row 1, to Column B formula to get the first column values:
=IF(MOD(ROW(A1)+2;3)=0;A1;"")
to Column C to get the second column values:
=IF(MOD(ROW(A1)+1;3)=0;A1;"")
and to Column D to get the third column values:
=IF(MOD(ROW(A1);3)=0;A1;"")
but this returns values to every row, with two of the columns being empty. So this is not ready, although it is a start.
Last edited: