how to transform text value in Pivot Table

Sian1

Board Regular
Joined
Nov 9, 2009
Messages
90
Hi, hope someone could assist how to transform the following table into Pivot in Text format

from the below table to this in Pivot perhaps or matrix? is it possible?
Column Labels
Row Labels0-25%26%-50%>50%
>1000Great Britain, U.S.A
101-1000Kuwait, Finland, Norway…
0-100


PO Vol BucketPO CountryPO %Rework Bucket
101-1000KUWAIT0-25%
>1000GREAT BRITAIN>50%
>1000U.S.A.26%-50%
101-1000FINLAND>50%
101-1000NORWAY26%-50%
>1000ITALY>50%
101-1000BELGIUM>50%
>1000FRANCE>50%
101-1000CANADA26%-50%
101-1000IRELAND>50%
101-1000CHINA (P.R.C.)>50%
>1000NETHERLANDS26%-50%
>1000GERMANY26%-50%
101-1000AUSTRIA26%-50%
101-1000SWITZERLAND>50%
101-1000SPAIN>50%
101-1000SWEDEN>50%
101-1000DENMARK>50%
101-1000PUERTO RICO>50%
101-1000JAPAN26%-50%
0-100NEW ZEALAND>50%
101-1000AUSTRALIA>50%
101-1000SINGAPORE>50%
101-1000UNITED ARAB EMIRATES26%-50%
0-100MALAYSIA>50%
0-100TAIWAN - CHINA26%-50%
101-1000BERMUDA>50%
101-1000INDIA>50%
101-1000SOUTH AFRICA26%-50%
101-1000RUSSIA0-25%
101-1000PORTUGAL26%-50%
101-1000HONG KONG>50%
0-100GREECE>50%
0-100BRAZIL>50%
101-1000MEXICO>50%
0-100QATAR0-25%
0-100ISRAEL26%-50%
0-100LEBANON0-25%
0-100PHILIPPINES26%-50%
0-100THAILAND0-25%
0-100EGYPT0-25%
0-100INDONESIA0-25%
0-100MALTA0-25%
0-100SOUTH KOREA26%-50%
0-100ECUADOR>50%
0-100VIETNAM0-25%
0-100KENYA0-25%
 

Excel Facts

What do {} around a formula in the formula bar mean?
{Formula} means the formula was entered using Ctrl+Shift+Enter signifying an old-style array formula.
Not a Pivot Table but see if this would do.

I have assumed that the bottom table is in the active sheet starting in A1 and that the results can go in columns E:H starting in row 1.

VBA Code:
Sub Rearrange()
  Dim a As Variant, b(1 To 3, 1 To 3) As Variant
  Dim i As Long, r As Long, c As Long
  
  Const rString As String = "1>10002101-100030-100"
  Const cString As String = "10-25%226%-50%3>50%"
  
  a = Range("A2", Range("C" & Rows.Count).End(xlUp)).Value
  For i = 1 To UBound(a)
    r = Mid(rString, InStr(rString, a(i, 1)) - 1, 1)
    c = Mid(cString, InStr(cString, a(i, 3)) - 1, 1)
    b(r, c) = b(r, c) & IIf(Len(b(r, c)) = 0, "", ", ") & a(i, 2)
  Next i
  With Range("F2:H4")
    .ColumnWidth = 60
    .WrapText = True
    .Value = b
    .Rows(0).Value = Array("0-25%", "26%-50%", ">50%")
    .Columns(0).Value = Application.Transpose(Array(">1000", "101-1000", "0-100"))
  End With
End Sub

For your sample data, this is my result:

Sian1.xlsm
EFGH
10-25%26%-50%>50%
2>1000U.S.A., NETHERLANDS, GERMANYGREAT BRITAIN, ITALY, FRANCE
3101-1000KUWAIT, RUSSIANORWAY, CANADA, AUSTRIA, JAPAN, UNITED ARAB EMIRATES, SOUTH AFRICA, PORTUGALFINLAND, BELGIUM, IRELAND, CHINA (P.R.C.), SWITZERLAND, SPAIN, SWEDEN, DENMARK, PUERTO RICO, AUSTRALIA, SINGAPORE, BERMUDA, INDIA, HONG KONG, MEXICO
40-100QATAR, LEBANON, THAILAND, EGYPT, INDONESIA, MALTA, VIETNAM, KENYATAIWAN - CHINA, ISRAEL, PHILIPPINES, SOUTH KOREANEW ZEALAND, MALAYSIA, GREECE, BRAZIL, ECUADOR
Sheet1
 
Upvote 0
Not a Pivot Table but see if this would do.

I have assumed that the bottom table is in the active sheet starting in A1 and that the results can go in columns E:H starting in row 1.

VBA Code:
Sub Rearrange()
  Dim a As Variant, b(1 To 3, 1 To 3) As Variant
  Dim i As Long, r As Long, c As Long
 
  Const rString As String = "1>10002101-100030-100"
  Const cString As String = "10-25%226%-50%3>50%"
 
  a = Range("A2", Range("C" & Rows.Count).End(xlUp)).Value
  For i = 1 To UBound(a)
    r = Mid(rString, InStr(rString, a(i, 1)) - 1, 1)
    c = Mid(cString, InStr(cString, a(i, 3)) - 1, 1)
    b(r, c) = b(r, c) & IIf(Len(b(r, c)) = 0, "", ", ") & a(i, 2)
  Next i
  With Range("F2:H4")
    .ColumnWidth = 60
    .WrapText = True
    .Value = b
    .Rows(0).Value = Array("0-25%", "26%-50%", ">50%")
    .Columns(0).Value = Application.Transpose(Array(">1000", "101-1000", "0-100"))
  End With
End Sub

For your sample data, this is my result:

Sian1.xlsm
EFGH
10-25%26%-50%>50%
2>1000U.S.A., NETHERLANDS, GERMANYGREAT BRITAIN, ITALY, FRANCE
3101-1000KUWAIT, RUSSIANORWAY, CANADA, AUSTRIA, JAPAN, UNITED ARAB EMIRATES, SOUTH AFRICA, PORTUGALFINLAND, BELGIUM, IRELAND, CHINA (P.R.C.), SWITZERLAND, SPAIN, SWEDEN, DENMARK, PUERTO RICO, AUSTRALIA, SINGAPORE, BERMUDA, INDIA, HONG KONG, MEXICO
40-100QATAR, LEBANON, THAILAND, EGYPT, INDONESIA, MALTA, VIETNAM, KENYATAIWAN - CHINA, ISRAEL, PHILIPPINES, SOUTH KOREANEW ZEALAND, MALAYSIA, GREECE, BRAZIL, ECUADOR
Sheet1
thanks so much Peter !!
 
Upvote 0
You're welcome. Thanks for the follow-up. :)
 
Upvote 0

Forum statistics

Threads
1,214,971
Messages
6,122,525
Members
449,088
Latest member
RandomExceller01

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