Consulting

Results 1 to 5 of 5

Thread: Solved: Transpose column A to rows

  1. #1
    VBAX Regular
    Joined
    Jun 2007
    Posts
    14
    Location

    Solved: Transpose column A to rows

    Been modifing several dozen excel sheets this week, latest problem,

    Column A down to A 5000 or so is populated with Formula.

    I need to transpose column A data every 25 may be more but this can be changed I assume by manually changing a macro.

    So move or copy all data in Column A in blocks of 25 to rows

    so row 1 would have 25 (column data A1 to A25)

    row 2 would have the next 25 (column data A26 to A50)

    row 3 woulde have the next 25 Column data A51 to 75)

    I could transpose manually but the task looks daunting,

    Can anyone assist please.


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

    Public Sub ProcessData()
    Dim i As Long
    Dim LastRow As Long

    With Application

    .ScreenUpdating = False
    .Calculation = xlCalculationManual
    .DisplayAlerts = False
    End With

    With ActiveSheet

    LastRow = .Cells(.Rows.Count, "A").End(xlUp).Row
    For i = LastRow + (25 - LastRow Mod 25) To 24 Step -25

    .Cells(i - 24, "A").Resize(25).Copy
    .Cells(i - 24, "B").PasteSpecial Paste:=xlPasteAll, Operation:=xlNone, Transpose:=True
    .Rows(i - 23).Resize(24).Delete
    Next i
    .Columns(1).Delete
    End With

    With Application

    .DisplayAlerts = True
    .Calculation = xlCalculationAutomatic
    .ScreenUpdating = True
    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 Regular
    Joined
    Jun 2007
    Posts
    14
    Location
    Many thanks - brilliant!

  4. #4
    Hey, I have a question, how about if I want to have blocks of rows of 9, is there a way your VBA can be changed to it? I changed some of the numbers in the VBA but I can't get it to work.

    Thanks in advance!!!.

  5. #5
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    Start a new thread and explain your situation there, maybe with an example workbook.
    ____________________________________________
    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

Posting Permissions

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