Transpose Data

Ruban S

New Member
Joined
Dec 31, 2019
Messages
35
Office Version
  1. 2016
Platform
  1. Windows
Dear All,

Please help me.

I have data like this

SHORTLONGNOUNMODIFIERATT N1ATT V1
BELT,A56BELT,DESIGNATION:A56BELT--DESIGNATIONA56
BELT,A57BELT,DESIGNATION:A57BELT--DESIGNATIONA57

And I want it like this

BELT,A56BELT,DESIGNATION:A56
BELT--
DESIGNATIONA56
BELT,A57BELT,DESIGNATION:A57
BELT--
DESIGNATIONA57
 

Excel Facts

Easy bullets in Excel
If you have a numeric keypad, press Alt+7 on numeric keypad to type a bullet in Excel.
with Power Query (Get&Transform)
Code:
// Table1
let
    Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
    Index1 = Table.AddIndexColumn(Table.SelectColumns(Table.Unpivot(Source, {"SHORT", "NOUN", "ATT N1"}, "Attribute", "Value"),{"Value"}), "Index", 1, 1),
    Index2 = Table.AddIndexColumn(Table.SelectColumns(Table.Unpivot(Source, {"LONG", "MODIFIER", "ATT V1"}, "Attribute", "Value"),{"Value"}), "Index", 1, 1),
    Result = Table.RemoveColumns(Table.ExpandTableColumn(Table.NestedJoin(Index1,{"Index"},Index2,{"Index"},"Index2",JoinKind.LeftOuter), "Index2", {"Value"}, {"Value.1"}),{"Index"})
in
    Result
merge.jpg
 
Upvote 0
Dear Power Query is restricted here. Can you please suggest any VBA Program
 
Upvote 0
How about
Rich (BB code):
Sub RubanS()
    Dim Oary As Variant, Nary As Variant
    Dim r As Long, c As Long, nr As Long
    
    Oary = Sheets("Sheet1").Range("A1").CurrentRegion.Value2
    ReDim Nary(1 To UBound(Oary) * UBound(Oary, 2) / 2, 1 To 2)
    For r = 2 To UBound(Oary)
        For c = 1 To UBound(Oary, 2) Step 2
            nr = nr + 1
            Nary(nr, 1) = Oary(r, c)
            Nary(nr, 2) = Oary(r, c + 1)
        Next c
    Next r
    Sheets("Sheet2").Range("A1").Resize(nr, 2).Value = Nary
End Sub
change sheet names to suit
 
Upvote 0
Dear Power Query is restricted here. Can you please suggest any VBA Program
I don't believe! Really?
You've Excel 2016 so you've Power Query (Get&Transform) built-in, so it cannot be prohibited.
 
Last edited:
Upvote 0
How about
Rich (BB code):
Sub RubanS()
    Dim Oary As Variant, Nary As Variant
    Dim r As Long, c As Long, nr As Long
   
    Oary = Sheets("Sheet1").Range("A1").CurrentRegion.Value2
    ReDim Nary(1 To UBound(Oary) * UBound(Oary, 2) / 2, 1 To 2)
    For r = 2 To UBound(Oary)
        For c = 1 To UBound(Oary, 2) Step 2
            nr = nr + 1
            Nary(nr, 1) = Oary(r, c)
            Nary(nr, 2) = Oary(r, c + 1)
        Next c
    Next r
    Sheets("Sheet2").Range("A1").Resize(nr, 2).Value = Nary
End Sub
change sheet names to suit



It is coming like this

1577955596260.png
 
Upvote 0
You need to change the sheet names to match your sheet names
 
Upvote 0

Forum statistics

Threads
1,215,777
Messages
6,126,834
Members
449,343
Latest member
DEWS2031

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