Changing the format/layout of an excel worksheet

sleepyowl86

New Member
Joined
Aug 26, 2014
Messages
14
I have a worksheet with over 3 months worth of data entry. My coworker claims she can't understand the layout. She wants me to change it from example 1 to example 2. Is there any easy way to do this without re-entering 3 months worth of work?

Example 1

WK#DateAccnt Name
17/9/15MY PLACE
28/6/15MY PLACE
38/13/15MY PLACE
48/20/15MY PLACE

<tbody>
</tbody>

Example 2
Acct NameWk 1Wk 2Wk 3Wk 4
My Place7/9/158/6/158/13/158/20/15

<tbody>
</tbody>

 

MickG

MrExcel MVP
Joined
Jan 9, 2008
Messages
14,841
Try this:-
Results sheet2
Code:
[COLOR="Navy"]Sub[/COLOR] MG16Sep15
[COLOR="Navy"]Dim[/COLOR] Rng [COLOR="Navy"]As[/COLOR] Range, Dn [COLOR="Navy"]As[/COLOR] Range, n [COLOR="Navy"]As[/COLOR] [COLOR="Navy"]Long,[/COLOR] oMax [COLOR="Navy"]As[/COLOR] [COLOR="Navy"]Long,[/COLOR] Q [COLOR="Navy"]As[/COLOR] Variant
[COLOR="Navy"]Set[/COLOR] Rng = Range(Range("C2"), Range("C" & Rows.Count).End(xlUp))
ReDim Ray(1 To Rng.Count, 1 To 2)
n = 1
[COLOR="Navy"]With[/COLOR] CreateObject("scripting.dictionary")
.CompareMode = vbTextCompare
    [COLOR="Navy"]For[/COLOR] [COLOR="Navy"]Each[/COLOR] Dn [COLOR="Navy"]In[/COLOR] Rng
        [COLOR="Navy"]If[/COLOR] Not .Exists(Dn.Value) [COLOR="Navy"]Then[/COLOR]
            n = n + 1
            Ray(1, 1) = "Account Name"
            Ray(n, 1) = Dn.Value: Ray(n, 2) = Dn.Offset(, -1).Value: Ray(1, 2) = "Wk " & Dn.Offset(, -2).Value
            .Add Dn.Value, Array(n, 2)
        [COLOR="Navy"]Else[/COLOR]
            Q = .Item(Dn.Value)
            Q(1) = Q(1) + 1
            oMax = Application.Max(Q(1), oMax)
            [COLOR="Navy"]If[/COLOR] UBound(Ray, 2) < oMax [COLOR="Navy"]Then[/COLOR] ReDim Preserve Ray(1 To Rng.Count, 1 To Q(1))
            Ray(1, Q(1) - 1) = "Wk " & Q(1) - 2
            Ray(Q(0), Q(1)) = Dn.Offset(, -1): Ray(1, Q(1)) = "Wk " & Dn.Offset(, -2).Value
            .Item(Dn.Value) = Q
        [COLOR="Navy"]End[/COLOR] If
[COLOR="Navy"]Next[/COLOR]
[COLOR="Navy"]End[/COLOR] With
[COLOR="Navy"]With[/COLOR] Sheets("Sheet2").Range("A1").Resize(n, oMax)
    .Value = Ray
    .Columns.AutoFit
    .Borders.Weight = 2
[COLOR="Navy"]End[/COLOR] [COLOR="Navy"]With[/COLOR]
[COLOR="Navy"]End[/COLOR] [COLOR="Navy"]Sub[/COLOR]
Regards Mick
 

Domski

Well-known Member
Joined
Jan 18, 2005
Messages
7,292
You could use Index/Match to create the table. I'd stick with your format if it was me though as you'll find it much easier to analyse data entered in a list like that than if it's already in a table format.

Dom
 

sleepyowl86

New Member
Joined
Aug 26, 2014
Messages
14
Mick- I had to learn a new skill but that almost worked perfectly. The problem I'm having is its not changing the entire list.


Dom- Thank you, that's what I thought too. But she'll throw a fit til she gets her way
 
Last edited:

sleepyowl86

New Member
Joined
Aug 26, 2014
Messages
14
Mick-Never mind, It moved my starting list down so I thought it only changed half my list! It works great!
 

Smitty

MrExcel MVP
Joined
May 15, 2003
Messages
29,536
You could also try a Pivot Table:

<b>Excel 2012</b><table cellpadding="2.5px" rules="all" style=";background-color: #FFFFFF;border: 1px solid;border-collapse: collapse; border-color: #BBB"><colgroup><col width="25px" style="background-color: #DAE7F5" /><col /><col /><col /><col /><col /></colgroup><thead><tr style=" background-color: #DAE7F5;text-align: center;color: #161120"><th></th><th>A</th><th>B</th><th>C</th><th>D</th><th>E</th></tr></thead><tbody><tr ><td style="color: #161120;text-align: center;">3</td><td style=";"> </td><td style=";">Week Number</td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style="text-align: right;;"></td></tr><tr ><td style="color: #161120;text-align: center;">4</td><td style=";">Account</td><td style="text-align: right;;">1</td><td style="text-align: right;;">2</td><td style="text-align: right;;">3</td><td style="text-align: right;;">4</td></tr><tr ><td style="color: #161120;text-align: center;">5</td><td style=";">MY PLACE</td><td style="text-align: right;;">07/09/15</td><td style="text-align: right;;">08/06/15</td><td style="text-align: right;;">08/13/15</td><td style="text-align: right;;">08/20/15</td></tr></tbody></table><p style="width:3.6em;font-weight:bold;margin:0;padding:0.2em 0.6em 0.2em 0.5em;border: 1px solid #BBB;border-top:none;text-align: center;background-color: #DAE7F5;color: #161120">Sheet4</p><br /><br />

HTH,
 

Forum statistics

Threads
1,082,276
Messages
5,364,195
Members
400,786
Latest member
ismi88

Some videos you may like

This Week's Hot Topics

  • populate from drop list with multiple tables
    Hi All, i have a drop list that displays data, what i want is when i select one of those from the list to populate text from different tables on...
  • Find list of words from sheet2 in sheet1 before a comma and extract text vba
    Hi Friends, Trying to find the solution on my task. But did not find suitable one to the need. Here is my query and sample file with details...
  • Dynamic Formula entry - VBA code sought
    Hello, really hope one of you experts can help with this - i've spent hours on this and getting no-where. .I have a set of data (more rows than...
  • Listbox Header
    Have a named range called "AccidentsHeader" Within my code I have: [CODE]Private Sub CommandButton1_Click() ListBox1.RowSource =...
  • Complex Heat Map using conditional formatting
    Good day excel world. I have a concern. Below link have a list of countries that carries each country unique data. [URL...
  • Conditional formatting
    Hi good morning, hope you can help me please, I have cells P4:P54 and if this cell is equal to 1 then i want row O to say "Fully Utilised" and to...
Top