+ Reply to Thread
Results 1 to 4 of 4

Thread: Cell Decomposition problem

  1. #1
    Registered User
    Join Date
    02-20-2009
    Location
    La, CA
    MS-Off Ver
    Excel 2003
    Posts
    70

    Cell Decomposition problem

    hey Leith, hey everyone

    i have a problem how to decompose the last cell, here's the table i'm using:

    A | B | C | D
    1 value value value M1/M2/M3
    2
    '
    '
    '
    n value value value S2/S4/S5

    i want it to look like this :

    A | B | C | D | E | F
    1 value value value M1 M2 M3
    2
    '
    '
    '
    n value value value S2 S4 S5


    need help plz
    thanks in advance

  2. #2
    Forum Guru JBeaucaire's Avatar
    Join Date
    03-21-2008
    Location
    Bakersfield, CA
    MS-Off Ver
    2010
    Posts
    19,226

    Re: Cell Decomposition problem

    Highlight the cell and select Data > Text To Columns > Delimited

    Click on [x] Space and [x] Other / and [x] treat consecutive delimiters as one

    ...and see if that gets you what you want.
    _________________
    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 Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & read 2007
    Posts
    15,979

    Re: Cell Decomposition problem

    Hello mehdoush,

    This macro will start with cell "D1" on worksheet "Sheet1" and continue down to the last entry in column "D". Cell data that is separated by a forward slashes will be place into the next successive column in the same row. The worksheet and range are marked in red if you need to change either one.
    Sub ExpandData()
    
      Dim Cell As Range
      Dim Data As Variant
      Dim Rng As Range
      Dim RngEnd As Range
      Dim RngStart As Range
      Dim Wks As Worksheet
      
        Set Rng = Worksheets("Sheet1").Range("D1")
        Set Wks = Rng.Parent
        
          With Wks
            Set RngEnd = .Cells(Rows.Count, Rng.Column).End(xlUp)
            Set RngEnd = IIf(RngEnd.Row < Rng.Row, Rng, RngEnd)
            Set Rng = .Range(Rng, RngEnd)
          End With
          
          For Each Cell In Rng
            Data = Split(Cell, "/")
            For I = 0 To UBound(Data)
              Cell.Offset(0, I) = Data(I)
            Next I
         Next Cell
          
    End Sub
    Sincerely,
    Leith Ross

    Remember To Do the Following....

    1. Use code tags. Place [CODE] before the first line of code and [/CODE] after the last line of code.
    2. Thank those who have helped you by clicking the Star below the post.
    3. Please mark your post [SOLVED] if it has been answered satisfactorily.


    Old Scottish Proverb...
    Luathaid gu deanamh maille! (Rushing causes delays!)

  4. #4
    Registered User
    Join Date
    02-20-2009
    Location
    La, CA
    MS-Off Ver
    Excel 2003
    Posts
    70

    Re: Cell Decomposition problem

    awesome Leith
    thanks JBeaucaire

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Tags for this Thread

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.2.0