Row to Column Data distribution

arahim01

New Member
Joined
Oct 30, 2018
Messages
2
Hi All,

I have tried to get data by using an excel formula. But I felt. Actually I want to generate data distribution from down row to column wise and right side.

Suppose, I have some data in row 1, 2, 3 and 4 by an household ID of that household's all 4 members. Now i want to take all members data to the same row and right side.

Please see the attached file. And help me please.
 

Excel Facts

Difference between two dates
Secret function! Use =DATEDIF(A2,B2,"Y")&" years"&=DATEDIF(A2,B2,"YM")&" months"&=DATEDIF(A2,B2,"MD")&" days"
This is best achieved with VBA, are you happy with a VBA solution or must it be a formula?
I can't help if you want a formula solution.
 
Upvote 0
This looks pretty good.
You'll have to format date cells and place headers at the top of the output sheet

Code:
Sub TableToColumns()
Application.ScreenUpdating = False
lastrow = Worksheets("RAW").Cells(Rows.Count, "A").End(xlUp).Row
Raw_Date = 0
Raw_Cluster = 0
Raw_Team = 0
Raw_Household = 0
j = 1
For i = 2 To lastrow
If Worksheets("RAW").Cells(i, 1) <> Raw_Date Or _
Worksheets("RAW").Cells(i, 2) <> Raw_Cluster Or _
Worksheets("RAW").Cells(i, 3) <> Raw_Team Or _
Worksheets("RAW").Cells(i, 4) <> Raw_Household Then
j = j + 1
k = 5
Worksheets("Dataset Template").Cells(j, 1) = Worksheets("RAW").Cells(i, 1)
Worksheets("Dataset Template").Cells(j, 2) = Worksheets("RAW").Cells(i, 2)
Worksheets("Dataset Template").Cells(j, 3) = Worksheets("RAW").Cells(i, 3)
Worksheets("Dataset Template").Cells(j, 4) = Worksheets("RAW").Cells(i, 4)
Raw_Date = Worksheets("RAW").Cells(i, 1)
Raw_Cluster = Worksheets("RAW").Cells(i, 2)
Raw_Team = Worksheets("RAW").Cells(i, 3)
Raw_Household = Worksheets("RAW").Cells(i, 4)
End If
For l = 0 To 7
Worksheets("Dataset Template").Cells(j, k + l) = Worksheets("RAW").Cells(i, 5 + l)
Next l
k = k + 8
Next i
End Sub
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,175
Members
453,021
Latest member
Justyna P

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