Results 1 to 7 of 7

Thread: Transponse help

  1. #1
    VBAX Regular
    Joined
    Jan 2016
    Posts
    12
    Location

    Question Transponse help

    Can I speed up this process, not a problem for a couple of people, but if there is 150+ any help is welcome

    As you can see in the pictures to get a result on the sheet 2 had to:

    1. copy from sheet 1 paste special into new sheet (marked Transpose option)
    2. select all cell with data and make degrees to 0
    3. double center cells, modify cell to bold, font size etc...
    4.repeat all for second person etc etc..

    Is there any VBA or Macro to have this prosses automatically as I write data from one sheet to get a result on the sheet 2

    Here is dropbox with an example workbook link...

    https://www.dropbox.com/s/ka2qvilazc...test.xlsx?dl=0

  2. #2
    VBAX Guru mancubus's Avatar
    Joined
    Dec 2010
    Location
    "Where I lay my head is home" :D
    Posts
    2,645
    you can post your workbook here.

    Go Advanced
    Manage Attachments
    Add Files
    Select Files
    Open
    Upload Files
    Done
    PLS DO NOT PM; OPEN A THREAD INSTEAD!!!

    1) Posting Code
    [CODE]PasteYourCodeHere[/CODE]
    (or paste your code, select it, click # button)

    2) Uploading File(s)
    Go Advanced / Attachments - Manage Attachments / Add Files / Select Files / Select the file(s) (multiple files can be selected while holding Ctrl key) / Upload Files / Done
    Replace company specific / sensitive / confidential data. Include so many rows and sheets etc in the uploaded workbook to enable the helpers visualize the data and table structure. Helpers do not need the entire workbook.

    3) Testing the Codes
    always back up your files before testing the codes.

    4) Marking the Thread as Solved
    from Thread Tools (on the top right corner, above the first message)

  3. #3
    VBAX Regular
    Joined
    Jan 2016
    Posts
    12
    Location

    Files

    Files for Transpose help
    Attached Files Attached Files

  4. #4
    VBAX Guru mancubus's Avatar
    Joined
    Dec 2010
    Location
    "Where I lay my head is home" :D
    Posts
    2,645
    thanks snb for getting me into the habit of using index function with arrays.



    that said, below will handle 1st and 4th steps.

    2nd and 3rd not clear to me.
    since they are about formatting, record a macro while manually formatting the cells in Columns A and B of sheet List2. then post your recorded macro here so we can insert/adopt it to below code.

    try this code with a copy of your file.

    Sub vbax_54847_Create_Separate_Tables_Each_Row_Transposed()
    'http://www.vbaexpress.com/forum/showthread.php?54847-Transponse-help
    
        Dim j As Long, k As Long
        Dim pList
    
        With Application
            .DisplayAlerts = False
            .ScreenUpdating = False
        End With
        
        Worksheets("List1").Copy After:=Worksheets(Worksheets.Count)
        
        With ActiveSheet
            .Rows(1).Delete
            .UsedRange.Rows(1).SpecialCells(xlCellTypeBlanks) = Chr(10)
            pList = Application.Transpose(.Cells(1).CurrentRegion.Value)
            .Delete
        End With
        
        k = 1
        With Worksheets("List2")
            .Cells.Clear 'clear existing data
            For j = 2 To UBound(pList, 2)
                .Cells(1, k).Resize(UBound(pList)).Value = Application.Index(pList, , 1)
                .Cells(1, k + 1).Resize(UBound(pList)).Value = Application.Index(pList, , j)
                k = k + 3
            Next
        End With
    End Sub
    PS: a table's top left cell must be A1 and first column (generally record id's) and first row (headers or field names) must contain no blank cells. below line inserts a non printinting character into blank cells in the header row. i chose Chr 10.

    .UsedRange.Rows(1).SpecialCells(xlCellTypeBlanks) = Chr(10)
    Last edited by mancubus; 01-15-2016 at 07:25 AM. Reason: explanation added.
    PLS DO NOT PM; OPEN A THREAD INSTEAD!!!

    1) Posting Code
    [CODE]PasteYourCodeHere[/CODE]
    (or paste your code, select it, click # button)

    2) Uploading File(s)
    Go Advanced / Attachments - Manage Attachments / Add Files / Select Files / Select the file(s) (multiple files can be selected while holding Ctrl key) / Upload Files / Done
    Replace company specific / sensitive / confidential data. Include so many rows and sheets etc in the uploaded workbook to enable the helpers visualize the data and table structure. Helpers do not need the entire workbook.

    3) Testing the Codes
    always back up your files before testing the codes.

    4) Marking the Thread as Solved
    from Thread Tools (on the top right corner, above the first message)

  5. #5
    VBAX Regular
    Joined
    Jan 2016
    Posts
    12
    Location
    Thank you Mancubus
    --------------------------------
    2nd and 3rd not clear to me.
    since they are about formatting, record a macro while manually formatting the cells in Columns A and B of sheet List2. then post your recorded macro here so we can insert/adopt it to below code.
    _________________________

    Here is a YouTube link that basically explains what I'm doing

  6. #6
    VBAX Regular
    Joined
    Jan 2016
    Posts
    12
    Location
    With slight modifications code works what I needed and for details using Format Painter.

    Thank you.

  7. #7
    VBAX Sage SamT's Avatar
    Joined
    Oct 2006
    Location
    Near Columbia
    Posts
    7,709
    Location
    Problem Solved? Use Thread Tools above the thread to mark it.
    I expect the student to do their homework and find all the errrors I leeve in.


    Please take the time to read the Forum FAQ

Posting Permissions

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