Consulting

Results 1 to 3 of 3

Thread: Solved: Layout of Monthly Data needs to change

  1. #1
    VBAX Tutor
    Joined
    Mar 2005
    Posts
    221
    Location

    Solved: Layout of Monthly Data needs to change

    Hello,

    Currently we recieve a forecast each month, and there is several tabs in it. It is not in a format that we can load into our tables, so we need to change it to be vertical rather than horizontal.

    I've attached a sample of how it comes, and how we'd ideally like to see it.
    I've tried to do it through formula's but I cannot seem to come up with something that can will include the date.

    Can someone please check out my sample attachment and share some insight on how this might be achieved?

  2. #2
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    [vba]

    Public Sub ProcessData()
    Const TEST_COLUMN As String = "A" '<=== change to suit
    Dim i As Long, j As Long
    Dim iLastRow As Long
    Dim iLastCol As Long
    Dim sh As Worksheet
    Dim thisSh As Worksheet
    Dim iRow As Long

    Set thisSh = ActiveSheet
    With thisSh

    Set sh = Worksheets.Add
    sh.Name = "Summary"
    iLastRow = .Cells(.Rows.Count, TEST_COLUMN).End(xlUp).Row
    iLastCol = .Cells(1, .Columns.Count).End(xlToLeft).Column
    iRow = 1
    For j = 2 To iLastCol Step 3
    .Range("A2").Resize(iLastRow - 1).Copy sh.Range("A" & iRow)
    .Cells(2, j).Resize(iLastRow - 1, 3).Copy sh.Range("B" & iRow)
    sh.Range("E" & iRow).Resize(iLastRow - 1).Value = .Cells(1, j)
    iRow = iRow + iLastRow - 1
    Next j
    sh.Columns(5).NumberFormat = thisSh.Range("B1").NumberFormat

    End With

    End Sub
    [/vba]
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  3. #3
    VBAX Tutor
    Joined
    Mar 2005
    Posts
    221
    Location
    Holy wicked!! That was awsome. I have not had a chance to fully understand your code , but this will work perfect!!

    You rock XLD. Hopefully I will understand it enough to modify a few other parts into it. Thanks!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •