LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 32
Default Reformat Data

Hi. I need to reorder my data based on the code below. I currently have
source data of:

A B C D E F G
RoomPeriod Term CrsCode Section Course Tchr
Craig 1 HS1 HSS1 2 Algebra C5
Craig 2 HS1 HSS1 6 Algebra C5
Craig 3 HS1 HSS1 1 Algebra C5
Craig 4 HS1 HSS1 4 Algebra C5
Craig 5 HS1 HSS1 5 Algebra C5

I need the results to be this; teacher along the left and course and room
number in the cells:

Tchr P1 P2 P3 P4 P5 P6
Craig Alg C-5 Alg C-5 Alg C-5 Alg C-5 Alg C-5


Can you help amend my code below to do this. I am not sure how to make the
course name and room number merge to one field in the grid from two cells:


Option Explicit
Dim wsSource As Worksheet
Dim wsTarget As Worksheet

Sub CreateGridRprt()
Dim srcsh As Worksheet, dstsh As Worksheet
Dim pcell As Range, tcell As Range
Dim pmax As Long, i As Long

Set srcsh = ActiveSheet
pmax = Application.Max(Columns("B"))
Set dstsh = Worksheets.Add(after:=srcsh)

Range("A1") = srcsh.Range("A1")
For i = 1 To pmax
Cells(1, i + 1) = "P" & i
Next

srcsh.Activate
Set pcell = Range("A2")
Do While (pcell < "")
Set tcell = dstsh.Columns("A") _
.Find(pcell.Value, LookIn:=xlValues, lookat:=xlWhole)
If tcell Is Nothing Then
Set tcell = dstsh.Cells(Cells.Rows.Count, "A") _
.End(xlUp).Cells(2, 1)
tcell = pcell
tcell.Cells(1, pcell.Cells(1, "B") + 1) = _
pcell.Cells(1, "F")
Else
If tcell.Cells(1, pcell.Cells(1, "B") + 1) < "" Then
tcell.Cells(1, pcell.Cells(1, "B") + 1) = _
tcell.Cells(1, pcell.Cells(1, "B") + 1) & _
", " & Chr(10) & pcell.Cells(1, "F")
tcell.Cells(1, pcell.Cells(1, "B") + 1). _
Interior.ColorIndex = 44 ' paint yellow
Else
tcell.Cells(1, pcell.Cells(1, "B") + 1) = _
pcell.Cells(1, "F")
End If
End If
Set pcell = pcell(2, "A")
Loop
'paint blank cell with gray color
dstsh.Cells.SpecialCells(xlCellTypeBlanks).Interio r.ColorIndex = 15
'just for adjusting column width
For i = 1 To pmax + 1
If Application.CountA(dstsh.Columns(i)) < 1 Then
dstsh.Columns(i).ColumnWidth = 20
dstsh.Columns(i).AutoFit
dstsh.Columns(i).ColumnWidth = dstsh.Columns(i).ColumnWidth + 1
End If
Next
'just for adjusting row's height
For Each pcell In dstsh.Range("A1").CurrentRegion
pcell.EntireRow.AutoFit

End Sub


Thanks in advance for your help.

 
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
excel data table reformat datamanipulator Excel Discussion (Misc queries) 0 January 8th 09 07:20 PM
How do I reformat data into ranges Jerry Excel Discussion (Misc queries) 1 July 15th 08 03:28 AM
Excel 2002 - ReFormat DATA mateo107 Excel Discussion (Misc queries) 3 April 12th 06 04:54 PM
Reformat data to vertical format Psydwaze Excel Discussion (Misc queries) 1 June 16th 05 05:32 PM
reformat contact data CarlJ Excel Programming 2 December 8th 04 01:55 AM


All times are GMT +1. The time now is 07:10 AM.

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"