+ Reply to Thread
Results 1 to 3 of 3

Vertical to horizontal one column and underneath

Hybrid View

  1. #1
    Forum Contributor
    Join Date
    09-30-2008
    Location
    London
    Posts
    127

    Vertical to horizontal one column and underneath

    Please see attached file.

    I have two columns “Branch” & “Part” in Data sheet.

    It look like below

    Branch Parts
    2 401442511
    2 401590491
    2 401660461
    2 401680181
    5 401221001
    5 401680211
    7 402590682
    8 401440292
    8 401442511
    8 401660391
    10 401330101
    10 401745751
    11 401110762
    11 401750962
    11 401860061
    11 657444130
    14 402590782

    I want to display Branch in horizontal and part underneath in to it like below

    2 5 7 8 10 11 14
    401442511 401221001 402590682 401440292 401330101 401110762 402590782
    401590491 401680211 401442511 401745751 401750962
    401660461 401660391 401860061
    401680181 657444130



    Please help me if you have any formula or macro to do automatically.

    Regards
    Vinay
    Attached Files Attached Files

  2. #2
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Vertical to horizontal one column and underneath

    1) Create a blank sheet called Report in your workbook.
    2) Right-click on the Report tab and select VIEW CODE
    3) Paste in this sheet macro:
    Private Sub Worksheet_Activate()
    Application.ScreenUpdating = False
    Application.EnableEvents = False
    
        Call BranchParts
    
    Application.ScreenUpdating = True
    Application.EnableEvents = True
    End Sub
    4) In the VBEditor, click on Insert > Module
    5) Paste in this macro:
    Option Explicit
    
    Sub BranchParts()
    'JBeaucaire  (10/14/2009)
    Dim Rng As Range, cell As Range, LR As Long
    
    Sheets("Report").Cells.Clear
    Sheets("Data").Activate
    Range("A:A").AdvancedFilter Action:=xlFilterCopy, CopyToRange:=Range("E1"), Unique:=True
    
    Range("E:E").Cut Sheets("Report").Range("A1")
    With Sheets("Report")
        .Range("A2:A255").Copy
        .Range("B1").PasteSpecial xlPasteAll, Transpose:=True
        .Range("A2:A255").Clear
        Set Rng = .Range("B1", .Cells(1, Columns.Count).End(xlToLeft))
    End With
        
    If ActiveSheet.AutoFilterMode = False Then Range("A1").AutoFilter
    
    For Each cell In Rng
        Range("A1").AutoFilter Field:=1, Criteria1:=cell
        LR = Range("A" & Rows.Count).End(xlUp).Row
        If LR > 1 Then Range("B2:B" & LR).Copy cell.Offset(1, 0)
    Next cell
    
    ActiveSheet.AutoFilterMode = False
    End Sub
    6) Close the VBeditor and save your sheet.

    Now, anytime you bring up the REPORT sheet onscreen, it will update itself using the macros you installed, so it will always be accurate.
    Attached Files Attached Files
    _________________
    Microsoft MVP 2010 - Excel
    Visit: Jerry Beaucaire's Excel Files & Macros

    If you've been given good help, use the icon below to give reputation feedback, it is appreciated.
    Always put your code between code tags. [CODE] your code here [/CODE]

    ?None of us is as good as all of us? - Ray Kroc
    ?Actually, I *am* a rocket scientist.? - JB (little ones count!)

  3. #3
    Forum Contributor
    Join Date
    09-30-2008
    Location
    London
    Posts
    127

    Re: Vertical to horizontal one column and underneath

    Hi JB,
    Great it' working perfect.

    Thank you very much.

    it's save lot of time.

    Regards

    Vinay

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1