+ Reply to Thread
Results 1 to 4 of 4

Re-organising data in excel

  1. #1
    Registered User
    Join Date
    02-10-2014
    Location
    Woking, England
    MS-Off Ver
    Excel 2003
    Posts
    2

    Re-organising data in excel

    Firstly hi to all - new to forums but hoping someone can help.

    I have been running some data exports from a booking system and have come across an annoying issue with addresses.

    Although all other entries are great with one row per transaction (unique booking number per entry) the address details have come out like below:

    The booking number and first line of address on one row - then a number of rows below for the rest of the address.

    I need this is the format of rows to columns - been trying the transpose for copy and paste but no luck.

    Any help would be appreciated.


    539-00000000001 Line1
    Line2
    Line3
    PCODE
    539-00000000002 ALine1
    ALine2
    ALine3
    ALine4
    APODE
    539-00000000003 L1
    L2
    L3
    L4
    L$PC

  2. #2
    Valued Forum Contributor
    Join Date
    03-29-2013
    Location
    United Kingdom
    MS-Off Ver
    Office/Excel 2013
    Posts
    1,749

    Re: Re-organising data in excel

    A sample file would be helpful if you can
    Elegant Simplicity............. Not Always

  3. #3
    Registered User
    Join Date
    02-10-2014
    Location
    Woking, England
    MS-Off Ver
    Excel 2003
    Posts
    2

    Re: Re-organising data in excel

    Hi Andy

    Thanks for the reply.

    After some late searching on the internet last night - I actually stumbled across a script on another forum that seems to do the job!

    Code below.

    Sub Macro1()

    Dim lngRowLast As Long, _
    lngRowPaste As Long, _
    lngColOffset As Long
    Dim rngCell As Range, _
    rngDataSet As Range
    Dim varDelimiter As Variant
    Dim strSourceTab As String, _
    strOutputTab As String

    varDelimiter = "-"
    'Tab name containing source data. Change to suit.
    strSourceTab = "Sheet1"
    'Tab name for data output. Change to suit.
    strOutputTab = "Sheet2"

    lngRowLast = Sheets(strSourceTab).Cells(Rows.Count, "A").End(xlUp).Row

    'Assumes the original dataset is in Column A and starts at Row 1. Change to suit.
    Set rngDataSet = Sheets(strSourceTab).Range("A1:A" & lngRowLast)

    Application.ScreenUpdating = False

    For Each rngCell In rngDataSet

    If Left(rngCell.Value, 1) = varDelimiter Then
    If lngRowPaste = 0 And lngColOffset = 0 Then
    lngRowPaste = 1
    lngColOffset = 1
    Else
    lngRowPaste = lngRowPaste + 1
    lngColOffset = 1
    End If
    ElseIf lngRowPaste = 0 And lngColOffset = 0 Then
    lngRowPaste = 1
    lngColOffset = 1
    End If

    Sheets(strOutputTab).Cells(lngRowPaste, lngColOffset).Value = rngCell.Value
    lngColOffset = lngColOffset + 1

    Next rngCell

    Application.ScreenUpdating = True

    End Sub

  4. #4
    Valued Forum Contributor
    Join Date
    03-29-2013
    Location
    United Kingdom
    MS-Off Ver
    Office/Excel 2013
    Posts
    1,749

    Re: Re-organising data in excel

    Nice one - As long as your happy

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Need help organising data
    By Arvon in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 09-06-2013, 05:26 AM
  2. Help re-organising the data
    By billos in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 12-12-2011, 12:14 PM
  3. Input filtering and organising the data.
    By supermario2k8 in forum Excel General
    Replies: 2
    Last Post: 05-01-2008, 06:00 PM
  4. Re-organising a table of data ?
    By sml in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 05-21-2007, 07:42 AM
  5. organising data in a worksheet
    By Graeme in forum Excel General
    Replies: 2
    Last Post: 12-14-2006, 06:43 PM

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