Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 336
Default VBA code to change matrix to list for Pivot table Analysis

I would like to convert a "budget spreadsheet" in Matrix form to a list for
use as a data Source for a Pivot Table. The matrix has a total of 16
columns, 4 columns define the information in the row (Ledger Code,
Description, etc.) and then 12 columns containing the data for the periods
(January - December).

What would be the best way to do this without lot's of cutting/pasting and
Paste Special Transpose?

Thanks for any help
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,298
Default VBA code to change matrix to list for Pivot table Analysis

try this:


Option Explicit
Sub Rebuilder()
'cols A-D are static
'cols E - P are months
' headers are row 6
' data is in 45 rows below headers

Dim mnth As Long
Const blockrows As Long = 45
Const headerrow As Long = 6
For mnth = 1 To 12 '(1 - 12 months + 4 for the column offset

'copy static block
With Cells(headerrow + blockrows * mnth + 1, 1).Resize(blockrows, 4)
.Value = _
Range(Cells(headerrow + 1, 1), Cells(headerrow + blockrows + 1,
4)).Value
End With
'copy month name
With Cells(headerrow + blockrows * mnth + 1, 5)
.Resize(blockrows, 1).Value = _
Cells(headerrow, 4 + mnth).Resize(, 1).Value
End With

'copy month data
With Cells(headerrow + blockrows * mnth + 1, 6)
.Resize(blockrows, 1).Value = _
Cells(headerrow + 1, 4 + mnth).Resize(blockrows).Value
End With


Next



End Sub



"Martin" wrote:

I would like to convert a "budget spreadsheet" in Matrix form to a list for
use as a data Source for a Pivot Table. The matrix has a total of 16
columns, 4 columns define the information in the row (Ledger Code,
Description, etc.) and then 12 columns containing the data for the periods
(January - December).

What would be the best way to do this without lot's of cutting/pasting and
Paste Special Transpose?

Thanks for any help

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
change pivot table in code Basil Excel Programming 0 November 24th 08 11:58 AM
#Value in Analysis Services Pivot Table Jim Thomlinson Excel Discussion (Misc queries) 1 May 16th 08 09:36 PM
Pivot Table Page Change Code PFLY Excel Discussion (Misc queries) 1 May 16th 08 12:42 AM
Pivot table and customer analysis ExcelHelpNeeded Excel Worksheet Functions 1 September 4th 07 07:38 PM
Pivot Table analysis [email protected] Excel Programming 0 May 2nd 06 07:31 AM


All times are GMT +1. The time now is 11:46 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"