Puzzler

tljenkin

Board Regular
Joined
Jun 14, 2007
Messages
147
I have a record thus:


Name Tag Week 1 Week 2

Peter hsdk £5 £10

How do I transpose this automatically so that I get the following results:

Week Name Tag Amount

Week 1 Peter hsdk £5
Week 2 Peter hsdk £10

Thanks
 
Actually ignore all above, here is screen shot 1 & 2

Screen shot 1
Excel Workbook
ABCDEFGHIJKL
2SeqUniqueTypeRegimeCohortHeritageProd AreaChannelPro/ReDirect/CMCWeek1Week2
311BudgetICOBSLTSB - Loans - RetailLTSBLoansRetailProactiveDirect1020
422BudgetICOBSHBOS - Loans - RetailHBOSLoansRetailProactiveDirect3040
Sheet1
Excel 2010
 
Upvote 0

Excel Facts

What is the fastest way to copy a formula?
If A2:A50000 contain data. Enter a formula in B2. Select B2. Double-click the Fill Handle and Excel will shoot the formula down to B50000.
Screenshot 2
Excel Workbook
ABCDEFGHIJKL
7WeekSeqUniqueTypeRegimeCohortHeritageProd AreaChannelPro/ReDirect/CMCTotal Complaints
8Week111BudgetICOBSLTSB - Loans - RetailLTSBLoansRetailProactiveDirect10
9Week222BudgetICOBSHBOS - Loans - RetailHBOSLoansRetailProactiveDirect20
Sheet1
Excel 2010
 
Upvote 0
tljenkin,


Are your titles in worksheet Sheet1, in row 2 like this?


Excel Workbook
ABCDEFGHIJKL
1
2SeqUniqueTypeRegimeCohortHeritageProd AreaChannelPro/ReDirect/CMCWeek1Week2
311BudgetICOBSLTSB - Loans - RetailLTSBLoansRetailProactiveDirect1020
422BudgetICOBSHBOS - Loans - RetailHBOSLoansRetailProactiveDirect3040
5
Sheet1





Or, are your titles in worksheet Sheet1, in row 1 like this?


Excel Workbook
ABCDEFGHIJKL
1SeqUniqueTypeRegimeCohortHeritageProd AreaChannelPro/ReDirect/CMCWeek1Week2
211BudgetICOBSLTSB - Loans - RetailLTSBLoansRetailProactiveDirect1020
322BudgetICOBSHBOS - Loans - RetailHBOSLoansRetailProactiveDirect3040
4
Sheet1
 
Upvote 0
tljenkin,


Sample raw data in worksheet Sheet1:


Excel Workbook
ABCDEFGHIJKLMNOPQR
1
2SeqUniqueTypeRegimeCohortHeritageProd AreaChannelPro/ReDirect/CMCWeek1Week2Week3Week4Week5Week6Week7Week8
311BudgetICOBSLTSB - Loans - RetailLTSBLoansRetailProactiveDirect1020152510201525
422BudgetICOBSHBOS - Loans - RetailHBOSLoansRetailProactiveDirect3040354530403545
5
Sheet1





After the macro in a new worksheet Results:


Excel Workbook
ABCDEFGHIJKL
1WeekSeqUniqueTypeRegimeCohortHeritageProd AreaChannelPro/ReDirect/CMCTotal Complaints
2Week111BudgetICOBSLTSB - Loans - RetailLTSBLoansRetailProactiveDirect10
3Week211BudgetICOBSLTSB - Loans - RetailLTSBLoansRetailProactiveDirect20
4Week311BudgetICOBSLTSB - Loans - RetailLTSBLoansRetailProactiveDirect15
5Week411BudgetICOBSLTSB - Loans - RetailLTSBLoansRetailProactiveDirect25
6Week511BudgetICOBSLTSB - Loans - RetailLTSBLoansRetailProactiveDirect10
7Week611BudgetICOBSLTSB - Loans - RetailLTSBLoansRetailProactiveDirect20
8Week711BudgetICOBSLTSB - Loans - RetailLTSBLoansRetailProactiveDirect15
9Week811BudgetICOBSLTSB - Loans - RetailLTSBLoansRetailProactiveDirect25
10Week122BudgetICOBSHBOS - Loans - RetailHBOSLoansRetailProactiveDirect30
11Week222BudgetICOBSHBOS - Loans - RetailHBOSLoansRetailProactiveDirect40
12Week322BudgetICOBSHBOS - Loans - RetailHBOSLoansRetailProactiveDirect35
13Week422BudgetICOBSHBOS - Loans - RetailHBOSLoansRetailProactiveDirect45
14Week522BudgetICOBSHBOS - Loans - RetailHBOSLoansRetailProactiveDirect30
15Week622BudgetICOBSHBOS - Loans - RetailHBOSLoansRetailProactiveDirect40
16Week722BudgetICOBSHBOS - Loans - RetailHBOSLoansRetailProactiveDirect35
17Week822BudgetICOBSHBOS - Loans - RetailHBOSLoansRetailProactiveDirect45
18
Results





Please TEST this FIRST in a COPY of your workbook (always make a backup copy before trying new code, you never know what you might lose).

1. Copy the below code, by highlighting the code and pressing the keys CTRL + C
2. Open your workbook
3. Press the keys ALT + F11 to open the Visual Basic Editor
4. Press the keys ALT + I to activate the Insert menu
5. Press M to insert a Standard Module
6. Where the cursor is flashing, paste the code by pressing the keys CTRL + V
7. Press the keys ALT + Q to exit the Editor, and return to Excel
8. To run the macro from Excel, open the workbook, and press ALT + F8 to display the Run Macro Dialog. Double Click the macro's name to Run it.


Code:
Option Explicit
Option Base 1
Sub ReorgDataV2()
' hiker95, 10/01/2011
' http://www.mrexcel.com/forum/showthread.php?t=581001
Dim w1 As Worksheet, wR As Worksheet
Dim I(), O()
Dim LR As Long, LC As Long, r As Long, c As Long, n As Long
Set w1 = Worksheets("Sheet1")
LR = w1.Cells.Find("*", , xlValues, xlWhole, xlByRows, xlPrevious, False).Row
LC = w1.Cells.Find("*", , xlValues, xlWhole, xlByColumns, xlPrevious, False).Column
I = w1.Range("A2").CurrentRegion.Resize(, LC).Value
ReDim O(1 To (LC - 11 + 1) * (LR - 1) + 1, 1 To 12)
O(1, 1) = "Week"
O(1, 2) = "Seq"
O(1, 3) = "Unique"
O(1, 4) = "Type"
O(1, 5) = "Regime"
O(1, 6) = "Cohort"
O(1, 7) = "Heritage"
O(1, 8) = "Prod Area"
O(1, 9) = "Channel"
O(1, 10) = "Pro/Re"
O(1, 11) = "Direct/CMC"
O(1, 12) = "Total Complaints"
n = 1
For r = 2 To UBound(I) Step 1
  For c = 11 To LC Step 1
    n = n + 1
    O(n, 1) = I(1, c)
    O(n, 2) = I(r, 1)
    O(n, 3) = I(r, 2)
    O(n, 4) = I(r, 3)
    O(n, 5) = I(r, 4)
    O(n, 6) = I(r, 5)
    O(n, 7) = I(r, 6)
    O(n, 8) = I(r, 7)
    O(n, 9) = I(r, 8)
    O(n, 10) = I(r, 9)
    O(n, 11) = I(r, 10)
    O(n, 12) = I(r, c)
  Next c
Next r
If Not Evaluate("ISREF(Results!A1)") Then Worksheets.Add(After:=w1).Name = "Results"
Set wR = Worksheets("Results")
wR.UsedRange.Clear
wR.Range("A1").Resize(UBound(O), 12).Value = O
wR.UsedRange.Columns.AutoFit
wR.Activate
End Sub


Before you use the macro with Excel 2007 or newer, save your workbook, Save As, a macro enabled workbook with the file extension .xlsm


Then run the ReorgDataV2 macro.
 
Upvote 0
Here are the results:

One small problem: it copies "total Complaints received" into cell A2 and repeats this at the start of each cycle

Can you tweak slightly?

Many Thanks
Excel Workbook
ABCDEFGHIJKL
1WeekSeqUniqueTypeRegimeCohortHeritageProd AreaChannelPro/ReDirect/CMCTotal Complaints
2Total Complaints Received11BudgetICOBSLTSB - Loans - RetailLTSBLoansRetailProactiveDirect0
304/05/201111BudgetICOBSLTSB - Loans - RetailLTSBLoansRetailProactiveDirect0
411/05/201111BudgetICOBSLTSB - Loans - RetailLTSBLoansRetailProactiveDirect0
518/05/201111BudgetICOBSLTSB - Loans - RetailLTSBLoansRetailProactiveDirect0
625/05/201111BudgetICOBSLTSB - Loans - RetailLTSBLoansRetailProactiveDirect0
701/06/201111BudgetICOBSLTSB - Loans - RetailLTSBLoansRetailProactiveDirect0
808/06/201111BudgetICOBSLTSB - Loans - RetailLTSBLoansRetailProactiveDirect0
915/06/201111BudgetICOBSLTSB - Loans - RetailLTSBLoansRetailProactiveDirect0
1022/06/201111BudgetICOBSLTSB - Loans - RetailLTSBLoansRetailProactiveDirect0
Results
Excel 2007
 
Upvote 0
Please remember that the titles or row headers for the original data start in row 2.

Thanks
 
Upvote 0
tljenkin,


Sample raw data in worksheet Sheet1 (row 1 hidden):


Excel Workbook
ABCDEFGHIJKL
2SeqUniqueTypeRegimeCohortHeritageProd AreaChannelPro/ReDirect/CMCWeek1Week2
311BudgetICOBSLTSB - Loans - RetailLTSBLoansRetailProactiveDirect1020
422BudgetICOBSHBOS - Loans - RetailHBOSLoansRetailProactiveDirect3040
5
Sheet1





After the macro in a new worksheet Results:


Excel Workbook
ABCDEFGHIJKL
1WeekSeqUniqueTypeRegimeCohortHeritageProd AreaChannelPro/ReDirect/CMCTotal Complaints
2Week111BudgetICOBSLTSB - Loans - RetailLTSBLoansRetailProactiveDirect10
3Week211BudgetICOBSLTSB - Loans - RetailLTSBLoansRetailProactiveDirect20
4Week122BudgetICOBSHBOS - Loans - RetailHBOSLoansRetailProactiveDirect30
5Week222BudgetICOBSHBOS - Loans - RetailHBOSLoansRetailProactiveDirect40
6
Results





The only way we are going to resolve the issue you are having, is for you to send me your actual workbook.

See my Private Message to you (top right hand corner of MrExcel, Welcome, tljenkin., Private Messages:
 
Upvote 0
tljenkin,

When I try to send you a Private Message I get the following:

tljenkin has chosen not to receive private messages or may not be allowed to receive private messages. Therefore you may not send your message to him/her.

If you are trying to send this message to multiple recipients, remove tljenkin from the recipient list and send the message again.




The only other way to resolve the issue is:

See below in my Signature block: You can upload your workbook to Box Net, mark the workbook for sharing, and provide us with a link to your workbook.
 
Upvote 0

Forum statistics

Threads
1,224,552
Messages
6,179,487
Members
452,917
Latest member
MrsMSalt

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