Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
frankybenali
 
Posts: n/a
Default "Unpivot Technique" - Changing a Table Into A List


I am trying to reorganize a table into a list and have used the
"unpivot' technique described by John Walkenbach:

http://j-walk.com/ss/excel/usertips/tip068.htm

However, there is a problem because the created list is huge so will
not fit in the worksheet (not enough rows). It will fit in if blanks
are ignored. Is there a way that I can get the blanks to be ignored?


--
frankybenali
------------------------------------------------------------------------
frankybenali's Profile: http://www.excelforum.com/member.php...o&userid=18707
View this thread: http://www.excelforum.com/showthread...hreadid=391219

  #2   Report Post  
Dave Peterson
 
Posts: n/a
Default

How about a macro?

Option Explicit
Sub testme()
Dim curWks As Worksheet
Dim newWks As Worksheet

Dim FirstRow As Long
Dim LastRow As Long
Dim FirstCol As Long
Dim LastCol As Long
Dim iRow As Long
Dim iCol As Long

Dim oRow As Long

Application.ScreenUpdating = False

Set curWks = Worksheets("sheet1")
Set newWks = Worksheets.Add

newWks.Range("a1").Resize(1, 3).Value _
= Array("Month", "Product", "Sales")

With curWks
FirstRow = 2 'headers in row 1
LastRow = .Cells(.Rows.Count, "A").End(xlUp).Row
FirstCol = 2 'headers in column A
LastCol = .Cells(1, .Columns.Count).End(xlToLeft).Column

If Application.CountA(.Range(.Cells(FirstRow, FirstCol), _
.Cells(LastRow, LastCol))) (.Rows.Count - 1) Then
MsgBox "too much data"
Exit Sub
End If


oRow = 1
For iRow = FirstRow To LastRow
If iRow Mod 50 = 0 Then
Application.StatusBar = "Processing row#: " _
& iRow & " @ " & Now
End If
For iCol = FirstCol To LastCol
If IsEmpty(.Cells(iRow, iCol)) Then
'do nothing
Else
oRow = oRow + 1
newWks.Cells(oRow, "A").Value = .Cells(iRow, 1).Value
newWks.Cells(oRow, "B").Value = .Cells(1, iCol).Value
newWks.Cells(oRow, "C").Value = .Cells(iRow, iCol).Value
End If
Next iCol
Next iRow
End With

With Application
.StatusBar = False
.ScreenUpdating = True
End With

End Sub

If you're new to macros, you may want to read David McRitchie's intro at:
http://www.mvps.org/dmcritchie/excel/getstarted.htm

frankybenali wrote:

I am trying to reorganize a table into a list and have used the
"unpivot' technique described by John Walkenbach:

http://j-walk.com/ss/excel/usertips/tip068.htm

However, there is a problem because the created list is huge so will
not fit in the worksheet (not enough rows). It will fit in if blanks
are ignored. Is there a way that I can get the blanks to be ignored?

--
frankybenali
------------------------------------------------------------------------
frankybenali's Profile: http://www.excelforum.com/member.php...o&userid=18707
View this thread: http://www.excelforum.com/showthread...hreadid=391219


--

Dave Peterson
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
list to table Joe Excel Worksheet Functions 0 July 21st 05 05:01 AM
no show all function in dropdown list in Pivot Table Eva Excel Discussion (Misc queries) 1 July 21st 05 02:28 AM
List Running Horizontally-Pivot Table Possible? Jugglertwo Excel Discussion (Misc queries) 3 December 24th 04 05:29 AM
Changing font size in a list box [email protected] Excel Discussion (Misc queries) 1 December 21st 04 04:07 PM
convert excel list to pivot table GI Excel Discussion (Misc queries) 0 December 6th 04 06:45 PM


All times are GMT +1. The time now is 02:59 PM.

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

About Us

"It's about Microsoft Excel"