+ Reply to Thread
Results 1 to 5 of 5

pair single column to multiple column

  1. #1
    Ross
    Guest

    pair single column to multiple column

    Does anybody know how to (NOT manually) convert in:

    0030 0039 日联飞翼证券亚洲有限公司
    0040 0049 富业证券投资有限公司
    0050 0059 通陆证券有限公司
    0060 0069 鼎成证券有限公司
    0080 0089 丰年证券投资有限公司
    0090 0099 泰山证券有限公司

    to:

    0030 0039 日联飞翼证券亚洲有限公司 0050 0059 通陆证券有限公司 0080 0089 丰年证券投资有限公司
    0040 0049 富业证券投资有限公司 0060 0069 鼎成证券有限公司 0090 0099 泰山证券有限公司


    certainly some criteria are to be used as division points (e.g. 3 columns,
    starting from some value 0080, ...)

    Thx in advance!!!



  2. #2
    Bob Phillips
    Guest

    Re: pair single column to multiple column

    Sub Test()
    Const kStep As Long = 4
    Dim rng As Range
    Dim iLastRow As Long
    Dim i As Long, j As Long

    iLastRow = Cells(Rows.Count, "A").End(xlUp).Row
    For i = 1 To iLastRow Step kStep
    For j = 1 To kStep - 1
    Cells(i, (j * 3) + 1).Value = Cells(i + j, "A").Value
    Cells(i, (j * 3) + 2).Value = Cells(i + j, "B").Value
    Cells(i, (j * 3) + 3).Value = Cells(i + j, "C").Value
    If rng Is Nothing Then
    Set rng = Cells(i + j, "A").EntireRow
    Else
    Set rng = Union(rng, Cells(i + j, "A").EntireRow)
    End If
    Next j
    Next i
    rng.Delete
    End Sub


    --
    HTH

    Bob Phillips

    "Ross" <[email protected]> wrote in message
    news:[email protected]...
    > Does anybody know how to (NOT manually) convert in:
    >
    > 0030 0039 日联飞翼证券亚洲有限公司
    > 0040 0049 富业证券投资有限公司
    > 0050 0059 通陆证券有限公司
    > 0060 0069 鼎成证券有限公司
    > 0080 0089 丰年证券投资有限公司
    > 0090 0099 泰山证券有限公司
    >
    > to:
    >
    > 0030 0039 日联飞翼证券亚洲有限公司 0050 0059

    通陆证券有限公司 0080 0089 丰年证券投资有限公司
    > 0040 0049 富业证券投资有限公司 0060 0069

    鼎成证券有限公司 0090 0099 泰山证券有限公司
    >
    >
    > certainly some criteria are to be used as division points (e.g. 3 columns,
    > starting from some value 0080, ...)
    >
    > Thx in advance!!!
    >
    >




  3. #3
    Bob Phillips
    Guest

    Re: pair single column to multiple column

    Sorry, kStep should be a value of 3, I tested with 4 and didn't revert it.

    --
    HTH

    Bob Phillips

    "Ross" <[email protected]> wrote in message
    news:[email protected]...
    > Does anybody know how to (NOT manually) convert in:
    >
    > 0030 0039 日联飞翼证券亚洲有限公司
    > 0040 0049 富业证券投资有限公司
    > 0050 0059 通陆证券有限公司
    > 0060 0069 鼎成证券有限公司
    > 0080 0089 丰年证券投资有限公司
    > 0090 0099 泰山证券有限公司
    >
    > to:
    >
    > 0030 0039 日联飞翼证券亚洲有限公司 0050 0059

    通陆证券有限公司 0080 0089 丰年证券投资有限公司
    > 0040 0049 富业证券投资有限公司 0060 0069

    鼎成证券有限公司 0090 0099 泰山证券有限公司
    >
    >
    > certainly some criteria are to be used as division points (e.g. 3 columns,
    > starting from some value 0080, ...)
    >
    > Thx in advance!!!
    >
    >




  4. #4
    Ross
    Guest

    Re: pair single column to multiple column


    "Bob Phillips" <[email protected]> wrote in message
    news:[email protected]...
    > Sub Test()
    > Const kStep As Long = 4
    > Dim rng As Range
    > Dim iLastRow As Long
    > Dim i As Long, j As Long
    >
    > iLastRow = Cells(Rows.Count, "A").End(xlUp).Row
    > For i = 1 To iLastRow Step kStep
    > For j = 1 To kStep - 1
    > Cells(i, (j * 3) + 1).Value = Cells(i + j, "A").Value
    > Cells(i, (j * 3) + 2).Value = Cells(i + j, "B").Value
    > Cells(i, (j * 3) + 3).Value = Cells(i + j, "C").Value
    > If rng Is Nothing Then
    > Set rng = Cells(i + j, "A").EntireRow
    > Else
    > Set rng = Union(rng, Cells(i + j, "A").EntireRow)
    > End If
    > Next j
    > Next i
    > rng.Delete
    > End Sub
    >
    >
    > --
    > HTH
    >
    > Bob Phillips
    >


    Dear Bob Phillips,
    where to run the above codes? thx again

    --Ross



  5. #5
    Bob Phillips
    Guest

    Re: pair single column to multiple column

    Go to the VB IDE (Alt-F11), insert a new module (menu Insert>Module), copy
    the code in there, and then in Excel goto menu Tools>Macro>Macros... and
    select and run Test.

    --
    HTH

    Bob Phillips

    "Ross" <[email protected]> wrote in message
    news:[email protected]...
    >
    > "Bob Phillips" <[email protected]> wrote in message
    > news:[email protected]...
    > > Sub Test()
    > > Const kStep As Long = 4
    > > Dim rng As Range
    > > Dim iLastRow As Long
    > > Dim i As Long, j As Long
    > >
    > > iLastRow = Cells(Rows.Count, "A").End(xlUp).Row
    > > For i = 1 To iLastRow Step kStep
    > > For j = 1 To kStep - 1
    > > Cells(i, (j * 3) + 1).Value = Cells(i + j, "A").Value
    > > Cells(i, (j * 3) + 2).Value = Cells(i + j, "B").Value
    > > Cells(i, (j * 3) + 3).Value = Cells(i + j, "C").Value
    > > If rng Is Nothing Then
    > > Set rng = Cells(i + j, "A").EntireRow
    > > Else
    > > Set rng = Union(rng, Cells(i + j, "A").EntireRow)
    > > End If
    > > Next j
    > > Next i
    > > rng.Delete
    > > End Sub
    > >
    > >
    > > --
    > > HTH
    > >
    > > Bob Phillips
    > >

    >
    > Dear Bob Phillips,
    > where to run the above codes? thx again
    >
    > --Ross
    >
    >




+ 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