Splitting Single Column Data Into Three

zaska

Well-known Member
Joined
Oct 24, 2010
Messages
1,046
Hi All!

I am having data in a single column ..nearly 10,000 cells..


Code:
column A

1 FLOWERS
ROSE
JASMIN
TULIP
2 DOGS
BULLDOG
GERMANSHEPHERED
I Would like to split this data AS

Code:
Column A    Column B   Column C

    1          FLOWERS    ROSE
    1          FLOWERS    JASMIN
    1          FLOWERS    TULIP
    2          DOGS        BULLDOG
    2          DOGS        GERMANSHEPHERED
Kindly suggest of any possible solution..which could save me a lot of time.
 
zaska,

What version of Excel are you using?

Please attach screenshots of your workbook or a sample workbook that accurately portrays your current workbook on one sheet, and what it should look like 'After' on another sheet.

This makes it much easier to see exactly what you want to do, as well as shows us whether there is a consistent number of rows between tables and such.

Here are three possible ways to post small (copyable) screen shots directly in your post:

Please post a screenshot of your sheet(s), what you have and what you expect to achieve, with Excel Jeanie HTML 4 (contains graphic instructions).
http://www.excel-jeanie-html.de/html/hlp_schnell_en.php

or
RichardSchollar’s beta HTML Maker -...his signature block at the bottom of his post

or
Borders-Copy-Paste


If you can not give us screenshots, you can upload your workbook to www.box.net and provide us with a link to your workbook.
 
Upvote 0

Excel Facts

Select all contiguous cells
Pressing Ctrl+* (asterisk) will select the "current region" - all contiguous cells in all directions.
Code:
Sub onetothree()
[c:e].ClearContents
Dim c, u(), e, s1, s2, k&
Set c = Range("a1")
c = Range(c, c(Rows.Count).End(3))
ReDim u(1 To UBound(c), 1 To 3)
For Each e In c
 If Not IsEmpty(e) Then
    If (UBound(Split(e, " ")) = 1) * (IsNumeric(Left(e, 1))) Then
        s1 = Split(e, " ", 2)(0)
        s2 = Split(e, " ", 2)(1)
    Else
        k = k + 1
        u(k, 3) = e
    End If
    u(k + 1, 1) = s1
    u(k + 1, 2) = s2
End If
Next e
[c1].Resize(k, 3) = u
End Sub
 
Upvote 0
zaska,


Sample raw data:


Excel Workbook
ABCDE
11 FLOWERS
2ROSE
3JASMIN
4TULIP
5
62 DOGS
7BULLDOG
8GERMANSHEPHERED
9
103 BOOKS
11SCIENTIFIC
12FICTION
13STORIES
14
156 CPM
163ICER
177SEAS
1810GUTE
19
207 RPM
2110
2220
2330
2440
25
Sheet1





After the new macro:


Excel Workbook
ABCDE
11 FLOWERS1FLOWERSROSE
2ROSE1FLOWERSJASMIN
3JASMIN1FLOWERSTULIP
4TULIP2DOGSBULLDOG
52DOGSGERMANSHEPHERED
62 DOGS3BOOKSSCIENTIFIC
7BULLDOG3BOOKSFICTION
8GERMANSHEPHERED3BOOKSSTORIES
96CPM3ICER
103 BOOKS6CPM7SEAS
11SCIENTIFIC6CPM10GUTE
12FICTION7RPM10
13STORIES7RPM20
147RPM30
156 CPM7RPM40
163ICER
177SEAS
1810GUTE
19
207 RPM
2110
2220
2330
2440
25
Sheet1





Please TEST this FIRST in a COPY of your workbook (always make a backup copy before trying new code, you never know what you might lose).


1. Copy the below code, by highlighting the code and pressing the keys CTRL + C
2. Open your workbook
3. Press the keys ALT + F11 to open the Visual Basic Editor
4. Press the keys ALT + I to activate the Insert menu
5. Press M to insert a Standard Module
6. Where the cursor is flashing, paste the code by pressing the keys CTRL + V
7. Press the keys ALT + Q to exit the Editor, and return to Excel
8. To run the macro from Excel, open the workbook, and press ALT + F8 to display the Run Macro Dialog. Double Click the macro's name to Run it.


Code:
Option Explicit
Sub SplitAV3()
' hiker95, 04/09/2011
' http://www.mrexcel.com/forum/showthread.php?t=542144
Dim AArea As Range, Sp, s As Long, NR As Long
Application.ScreenUpdating = False
Columns("C:E").ClearContents
NR = 1
For Each AArea In Range("A1", Range("A" & Rows.Count).End(xlUp)).SpecialCells(xlCellTypeConstants).Areas
  With AArea
    Sp = Split(Cells(.Row, 1), " ")
    s = .Row + .Rows.Count - 1 - .Row
    Range("C" & NR).Resize(s, 2).Value = Sp
    Range("E" & NR).Resize(s).Value = Range("A" & .Row + 1 & ":A" & .Row + .Rows.Count - 1).Value
    NR = Range("C" & Rows.Count).End(xlUp).Offset(1).Row
  End With
Next AArea
Columns("C:E").AutoFit
Application.ScreenUpdating = True
End Sub


Then run the SplitAV3 macro.
 
Upvote 0
Hi,

Sample Data

<table border="0" cellpadding="0" cellspacing="0" width="171"><col style="mso-width-source:userset;mso-width-alt:6253;width:128pt" width="171"> <tbody><tr style="height:15.0pt" height="20"> <td class="xl65" style="height:15.0pt;width:128pt; font-size:11.0pt;color:red;font-weight:700;text-decoration:none;text-underline-style: none;text-line-through:none;font-family:Arial;border-top:none;border-right: none;border-bottom:1.5pt solid white;border-left:none;background:#4F81BD; mso-pattern:#4F81BD none" height="20" width="171">1 FlOWERS</td> </tr> <tr style="height:14.25pt" height="19"> <td class="xl66" style="height:14.25pt;font-size:11.0pt;color:black; font-weight:400;text-decoration:none;text-underline-style:none;text-line-through: none;font-family:Arial;border-top:.5pt solid white;border-right:none; border-bottom:.5pt solid white;border-left:none;background:#B8CCE4; mso-pattern:#B8CCE4 none" height="19">Rose</td> </tr> <tr style="height:14.25pt" height="19"> <td class="xl66" style="height:14.25pt;font-size:11.0pt;color:black; font-weight:400;text-decoration:none;text-underline-style:none;text-line-through: none;font-family:Arial;border-top:.5pt solid white;border-right:none; border-bottom:.5pt solid white;border-left:none;background:#DCE6F1; mso-pattern:#DCE6F1 none" height="19">Jasmin</td> </tr> <tr style="height:14.25pt" height="19"> <td class="xl66" style="height:14.25pt;font-size:11.0pt;color:black; font-weight:400;text-decoration:none;text-underline-style:none;text-line-through: none;font-family:Arial;border-top:.5pt solid white;border-right:none; border-bottom:.5pt solid white;border-left:none;background:#B8CCE4; mso-pattern:#B8CCE4 none" height="19">Tulip</td> </tr> <tr style="height:14.25pt" height="19"> <td class="xl66" style="height:14.25pt;font-size:11.0pt;color:black; font-weight:400;text-decoration:none;text-underline-style:none;text-line-through: none;font-family:Arial;border-top:.5pt solid white;border-right:none; border-bottom:.5pt solid white;border-left:none;background:#DCE6F1; mso-pattern:#DCE6F1 none" height="19">Lily</td> </tr> <tr style="height:14.25pt" height="19"> <td class="xl64" style="height:14.25pt;font-size:11.0pt;color:black; font-weight:400;text-decoration:none;text-underline-style:none;text-line-through: none;font-family:Arial;border-top:.5pt solid white;border-right:none; border-bottom:.5pt solid white;border-left:none;background:#B8CCE4; mso-pattern:#B8CCE4 none" height="19">
</td> </tr> <tr style="height:15.0pt" height="20"> <td class="xl65" style="height:15.0pt;font-size:11.0pt;color:red; font-weight:700;text-decoration:none;text-underline-style:none;text-line-through: none;font-family:Arial;border-top:.5pt solid white;border-right:none; border-bottom:.5pt solid white;border-left:none;background:#DCE6F1; mso-pattern:#DCE6F1 none" height="20">2 DOGS</td> </tr> <tr style="height:14.25pt" height="19"> <td class="xl66" style="height:14.25pt;font-size:11.0pt;color:black; font-weight:400;text-decoration:none;text-underline-style:none;text-line-through: none;font-family:Arial;border-top:.5pt solid white;border-right:none; border-bottom:.5pt solid white;border-left:none;background:#B8CCE4; mso-pattern:#B8CCE4 none" height="19">German shephered</td> </tr> <tr style="height:14.25pt" height="19"> <td class="xl66" style="height:14.25pt;font-size:11.0pt;color:black; font-weight:400;text-decoration:none;text-underline-style:none;text-line-through: none;font-family:Arial;border-top:.5pt solid white;border-right:none; border-bottom:.5pt solid white;border-left:none;background:#DCE6F1; mso-pattern:#DCE6F1 none" height="19">Bulldog</td> </tr> <tr style="height:14.25pt" height="19"> <td class="xl64" style="height:14.25pt;font-size:11.0pt;color:black; font-weight:400;text-decoration:none;text-underline-style:none;text-line-through: none;font-family:Arial;border-top:.5pt solid white;border-right:none; border-bottom:.5pt solid white;border-left:none;background:#B8CCE4; mso-pattern:#B8CCE4 none" height="19">
</td> </tr> <tr style="height:15.0pt" height="20"> <td class="xl65" style="height:15.0pt;font-size:11.0pt;color:red; font-weight:700;text-decoration:none;text-underline-style:none;text-line-through: none;font-family:Arial;border-top:.5pt solid white;border-right:none; border-bottom:.5pt solid white;border-left:none;background:#DCE6F1; mso-pattern:#DCE6F1 none" height="20">3 Auto</td> </tr> <tr style="height:14.25pt" height="19"> <td class="xl66" style="height:14.25pt;font-size:11.0pt;color:black; font-weight:400;text-decoration:none;text-underline-style:none;text-line-through: none;font-family:Arial;border-top:.5pt solid white;border-right:none; border-bottom:.5pt solid white;border-left:none;background:#B8CCE4; mso-pattern:#B8CCE4 none" height="19">3Star Auto</td> </tr> <tr style="height:14.25pt" height="19"> <td class="xl66" style="height:14.25pt;font-size:11.0pt;color:black; font-weight:400;text-decoration:none;text-underline-style:none;text-line-through: none;font-family:Arial;border-top:.5pt solid white;border-right:none; border-bottom:.5pt solid white;border-left:none;background:#DCE6F1; mso-pattern:#DCE6F1 none" height="19">5Star Auto</td> </tr> <tr style="height:14.25pt" height="19"> <td class="xl66" style="height:14.25pt;font-size:11.0pt;color:black; font-weight:400;text-decoration:none;text-underline-style:none;text-line-through: none;font-family:Arial;border-top:.5pt solid white;border-right:none; border-bottom:none;border-left:none;background:#B8CCE4;mso-pattern:#B8CCE4 none" height="19">6Star Auto</td> </tr> </tbody></table>
I tried the new macro and got the following output

<table border="0" cellpadding="0" cellspacing="0" width="299"><col style="mso-width-source:userset;mso-width-alt:2962; width:61pt" span="2" width="81"> <col style="mso-width-source:userset;mso-width-alt:5010;width:103pt" width="137"> <tbody><tr style="height:15.0pt" height="20"> <td class="xl65" style="height:15.0pt;width:61pt;font-size: 11.0pt;color:white;font-weight:700;text-decoration:none;text-underline-style: none;text-line-through:none;font-family:Arial;border-top:none;border-right: .5pt solid white;border-bottom:1.5pt solid white;border-left:none;background: #4F81BD;mso-pattern:#4F81BD none" height="20" width="81">Column1</td> <td class="xl65" style="width:61pt;font-size:11.0pt;color:white; font-weight:700;text-decoration:none;text-underline-style:none;text-line-through: none;font-family:Arial;border-top:none;border-right:.5pt solid white; border-bottom:1.5pt solid white;border-left:.5pt solid white;background:#4F81BD; mso-pattern:#4F81BD none" width="81">Column2</td> <td class="xl65" style="width:103pt;font-size:11.0pt;color:white; font-weight:700;text-decoration:none;text-underline-style:none;text-line-through: none;font-family:Arial;border-top:none;border-right:none;border-bottom:1.5pt solid white; border-left:.5pt solid white;background:#4F81BD;mso-pattern:#4F81BD none" width="137">Column3</td> </tr> <tr style="height:14.25pt" height="19"> <td class="xl65" style="height:14.25pt;font-size:11.0pt;color:black; font-weight:400;text-decoration:none;text-underline-style:none;text-line-through: none;font-family:Arial;border-top:.5pt solid white;border-right:.5pt solid white; border-bottom:.5pt solid white;border-left:none;background:#B8CCE4; mso-pattern:#B8CCE4 none" height="19">1</td> <td class="xl65" style="font-size:11.0pt;color:black;font-weight:400; text-decoration:none;text-underline-style:none;text-line-through:none; font-family:Arial;border:.5pt solid white;background:#B8CCE4;mso-pattern: #B8CCE4 none">
</td> <td class="xl65" style="font-size:11.0pt;color:black;font-weight:400; text-decoration:none;text-underline-style:none;text-line-through:none; font-family:Arial;border-top:.5pt solid white;border-right:none;border-bottom: .5pt solid white;border-left:.5pt solid white;background:#B8CCE4;mso-pattern: #B8CCE4 none">Rose</td> </tr> <tr style="height:14.25pt" height="19"> <td class="xl65" style="height:14.25pt;font-size:11.0pt;color:black; font-weight:400;text-decoration:none;text-underline-style:none;text-line-through: none;font-family:Arial;border-top:.5pt solid white;border-right:.5pt solid white; border-bottom:.5pt solid white;border-left:none;background:#DCE6F1; mso-pattern:#DCE6F1 none" height="19">1</td> <td class="xl65" style="font-size:11.0pt;color:black;font-weight:400; text-decoration:none;text-underline-style:none;text-line-through:none; font-family:Arial;border:.5pt solid white;background:#DCE6F1;mso-pattern: #DCE6F1 none">
</td> <td class="xl65" style="font-size:11.0pt;color:black;font-weight:400; text-decoration:none;text-underline-style:none;text-line-through:none; font-family:Arial;border-top:.5pt solid white;border-right:none;border-bottom: .5pt solid white;border-left:.5pt solid white;background:#DCE6F1;mso-pattern: #DCE6F1 none">Jasmin</td> </tr> <tr style="height:14.25pt" height="19"> <td class="xl65" style="height:14.25pt;font-size:11.0pt;color:black; font-weight:400;text-decoration:none;text-underline-style:none;text-line-through: none;font-family:Arial;border-top:.5pt solid white;border-right:.5pt solid white; border-bottom:.5pt solid white;border-left:none;background:#B8CCE4; mso-pattern:#B8CCE4 none" height="19">1</td> <td class="xl65" style="font-size:11.0pt;color:black;font-weight:400; text-decoration:none;text-underline-style:none;text-line-through:none; font-family:Arial;border:.5pt solid white;background:#B8CCE4;mso-pattern: #B8CCE4 none">
</td> <td class="xl65" style="font-size:11.0pt;color:black;font-weight:400; text-decoration:none;text-underline-style:none;text-line-through:none; font-family:Arial;border-top:.5pt solid white;border-right:none;border-bottom: .5pt solid white;border-left:.5pt solid white;background:#B8CCE4;mso-pattern: #B8CCE4 none">Tulip</td> </tr> <tr style="height:14.25pt" height="19"> <td class="xl65" style="height:14.25pt;font-size:11.0pt;color:black; font-weight:400;text-decoration:none;text-underline-style:none;text-line-through: none;font-family:Arial;border-top:.5pt solid white;border-right:.5pt solid white; border-bottom:.5pt solid white;border-left:none;background:#DCE6F1; mso-pattern:#DCE6F1 none" height="19">1</td> <td class="xl65" style="font-size:11.0pt;color:black;font-weight:400; text-decoration:none;text-underline-style:none;text-line-through:none; font-family:Arial;border:.5pt solid white;background:#DCE6F1;mso-pattern: #DCE6F1 none">
</td> <td class="xl65" style="font-size:11.0pt;color:black;font-weight:400; text-decoration:none;text-underline-style:none;text-line-through:none; font-family:Arial;border-top:.5pt solid white;border-right:none;border-bottom: .5pt solid white;border-left:.5pt solid white;background:#DCE6F1;mso-pattern: #DCE6F1 none">Lily</td> </tr> <tr style="height:14.25pt" height="19"> <td class="xl65" style="height:14.25pt;font-size:11.0pt;color:black; font-weight:400;text-decoration:none;text-underline-style:none;text-line-through: none;font-family:Arial;border-top:.5pt solid white;border-right:.5pt solid white; border-bottom:.5pt solid white;border-left:none;background:#B8CCE4; mso-pattern:#B8CCE4 none" height="19">2</td> <td class="xl65" style="font-size:11.0pt;color:black;font-weight:400; text-decoration:none;text-underline-style:none;text-line-through:none; font-family:Arial;border:.5pt solid white;background:#B8CCE4;mso-pattern: #B8CCE4 none">
</td> <td class="xl65" style="font-size:11.0pt;color:black;font-weight:400; text-decoration:none;text-underline-style:none;text-line-through:none; font-family:Arial;border-top:.5pt solid white;border-right:none;border-bottom: .5pt solid white;border-left:.5pt solid white;background:#B8CCE4;mso-pattern: #B8CCE4 none">German shephered</td> </tr> <tr style="height:15.0pt" height="20"> <td class="xl65" style="height:15.0pt;font-size:11.0pt;color:black; font-weight:400;text-decoration:none;text-underline-style:none;text-line-through: none;font-family:Arial;border-top:.5pt solid white;border-right:.5pt solid white; border-bottom:.5pt solid white;border-left:none;background:#DCE6F1; mso-pattern:#DCE6F1 none" height="20">2</td> <td class="xl65" style="font-size:11.0pt;color:black;font-weight:400; text-decoration:none;text-underline-style:none;text-line-through:none; font-family:Arial;border:.5pt solid white;background:#DCE6F1;mso-pattern: #DCE6F1 none">
</td> <td class="xl65" style="font-size:11.0pt;color:black;font-weight:400; text-decoration:none;text-underline-style:none;text-line-through:none; font-family:Arial;border-top:.5pt solid white;border-right:none;border-bottom: .5pt solid white;border-left:.5pt solid white;background:#DCE6F1;mso-pattern: #DCE6F1 none">Bulldog</td> </tr> <tr style="height:14.25pt" height="19"> <td class="xl65" style="height:14.25pt;font-size:11.0pt;color:black; font-weight:400;text-decoration:none;text-underline-style:none;text-line-through: none;font-family:Arial;border-top:.5pt solid white;border-right:.5pt solid white; border-bottom:.5pt solid white;border-left:none;background:#B8CCE4; mso-pattern:#B8CCE4 none" height="19">3</td> <td class="xl65" style="font-size:11.0pt;color:black;font-weight:400; text-decoration:none;text-underline-style:none;text-line-through:none; font-family:Arial;border:.5pt solid white;background:#B8CCE4;mso-pattern: #B8CCE4 none">
</td> <td class="xl65" style="font-size:11.0pt;color:black;font-weight:400; text-decoration:none;text-underline-style:none;text-line-through:none; font-family:Arial;border-top:.5pt solid white;border-right:none;border-bottom: .5pt solid white;border-left:.5pt solid white;background:#B8CCE4;mso-pattern: #B8CCE4 none">3Star Auto</td> </tr> <tr style="height:14.25pt" height="19"> <td class="xl65" style="height:14.25pt;font-size:11.0pt;color:black; font-weight:400;text-decoration:none;text-underline-style:none;text-line-through: none;font-family:Arial;border-top:.5pt solid white;border-right:.5pt solid white; border-bottom:.5pt solid white;border-left:none;background:#DCE6F1; mso-pattern:#DCE6F1 none" height="19">3</td> <td class="xl65" style="font-size:11.0pt;color:black;font-weight:400; text-decoration:none;text-underline-style:none;text-line-through:none; font-family:Arial;border:.5pt solid white;background:#DCE6F1;mso-pattern: #DCE6F1 none">
</td> <td class="xl65" style="font-size:11.0pt;color:black;font-weight:400; text-decoration:none;text-underline-style:none;text-line-through:none; font-family:Arial;border-top:.5pt solid white;border-right:none;border-bottom: .5pt solid white;border-left:.5pt solid white;background:#DCE6F1;mso-pattern: #DCE6F1 none">5Star Auto</td> </tr> <tr style="height:14.25pt" height="19"> <td class="xl65" style="height:14.25pt;font-size:11.0pt;color:black; font-weight:400;text-decoration:none;text-underline-style:none;text-line-through: none;font-family:Arial;border-top:.5pt solid white;border-right:.5pt solid white; border-bottom:none;border-left:none;background:#B8CCE4;mso-pattern:#B8CCE4 none" height="19">3</td> <td class="xl65" style="font-size:11.0pt;color:black;font-weight:400; text-decoration:none;text-underline-style:none;text-line-through:none; font-family:Arial;border-top:.5pt solid white;border-right:.5pt solid white; border-bottom:none;border-left:.5pt solid white;background:#B8CCE4; mso-pattern:#B8CCE4 none">
</td> <td class="xl65" style="font-size:11.0pt;color:black;font-weight:400; text-decoration:none;text-underline-style:none;text-line-through:none; font-family:Arial;border-top:.5pt solid white;border-right:none;border-bottom: none;border-left:.5pt solid white;background:#B8CCE4;mso-pattern:#B8CCE4 none">6Star Auto</td> </tr> </tbody></table>
Desired Output

<table border="0" cellpadding="0" cellspacing="0" width="299"><col style="mso-width-source:userset;mso-width-alt:2962; width:61pt" span="2" width="81"> <col style="mso-width-source:userset;mso-width-alt:5010;width:103pt" width="137"> <tbody><tr style="height:15.0pt" height="20"> <td class="xl65" style="height:15.0pt;width:61pt;font-size: 11.0pt;color:white;font-weight:700;text-decoration:none;text-underline-style: none;text-line-through:none;font-family:Arial;border-top:none;border-right: .5pt solid white;border-bottom:1.5pt solid white;border-left:none;background: #4F81BD;mso-pattern:#4F81BD none" height="20" width="81">Column1</td> <td class="xl65" style="width:61pt;font-size:11.0pt;color:white; font-weight:700;text-decoration:none;text-underline-style:none;text-line-through: none;font-family:Arial;border-top:none;border-right:.5pt solid white; border-bottom:1.5pt solid white;border-left:.5pt solid white;background:#4F81BD; mso-pattern:#4F81BD none" width="81">Column2</td> <td class="xl65" style="width:103pt;font-size:11.0pt;color:white; font-weight:700;text-decoration:none;text-underline-style:none;text-line-through: none;font-family:Arial;border-top:none;border-right:none;border-bottom:1.5pt solid white; border-left:.5pt solid white;background:#4F81BD;mso-pattern:#4F81BD none" width="137">Column3</td> </tr> <tr style="height:14.25pt" height="19"> <td class="xl65" style="height:14.25pt;font-size:11.0pt;color:black; font-weight:400;text-decoration:none;text-underline-style:none;text-line-through: none;font-family:Arial;border-top:.5pt solid white;border-right:.5pt solid white; border-bottom:.5pt solid white;border-left:none;background:#B8CCE4; mso-pattern:#B8CCE4 none" height="19">1</td> <td class="xl65" style="font-size:11.0pt;color:black;font-weight:400; text-decoration:none;text-underline-style:none;text-line-through:none; font-family:Arial;border:.5pt solid white;background:#B8CCE4;mso-pattern: #B8CCE4 none">FLOWERS</td> <td class="xl65" style="font-size:11.0pt;color:black;font-weight:400; text-decoration:none;text-underline-style:none;text-line-through:none; font-family:Arial;border-top:.5pt solid white;border-right:none;border-bottom: .5pt solid white;border-left:.5pt solid white;background:#B8CCE4;mso-pattern: #B8CCE4 none">Rose</td> </tr> <tr style="height:14.25pt" height="19"> <td class="xl65" style="height:14.25pt;font-size:11.0pt;color:black; font-weight:400;text-decoration:none;text-underline-style:none;text-line-through: none;font-family:Arial;border-top:.5pt solid white;border-right:.5pt solid white; border-bottom:.5pt solid white;border-left:none;background:#DCE6F1; mso-pattern:#DCE6F1 none" height="19">1</td> <td class="xl65" style="font-size:11.0pt;color:black;font-weight:400; text-decoration:none;text-underline-style:none;text-line-through:none; font-family:Arial;border:.5pt solid white;background:#DCE6F1;mso-pattern: #DCE6F1 none">FLOWERS</td> <td class="xl65" style="font-size:11.0pt;color:black;font-weight:400; text-decoration:none;text-underline-style:none;text-line-through:none; font-family:Arial;border-top:.5pt solid white;border-right:none;border-bottom: .5pt solid white;border-left:.5pt solid white;background:#DCE6F1;mso-pattern: #DCE6F1 none">Jasmin</td> </tr> <tr style="height:14.25pt" height="19"> <td class="xl65" style="height:14.25pt;font-size:11.0pt;color:black; font-weight:400;text-decoration:none;text-underline-style:none;text-line-through: none;font-family:Arial;border-top:.5pt solid white;border-right:.5pt solid white; border-bottom:.5pt solid white;border-left:none;background:#B8CCE4; mso-pattern:#B8CCE4 none" height="19">1</td> <td class="xl65" style="font-size:11.0pt;color:black;font-weight:400; text-decoration:none;text-underline-style:none;text-line-through:none; font-family:Arial;border:.5pt solid white;background:#B8CCE4;mso-pattern: #B8CCE4 none">FLOWERS</td> <td class="xl65" style="font-size:11.0pt;color:black;font-weight:400; text-decoration:none;text-underline-style:none;text-line-through:none; font-family:Arial;border-top:.5pt solid white;border-right:none;border-bottom: .5pt solid white;border-left:.5pt solid white;background:#B8CCE4;mso-pattern: #B8CCE4 none">Tulip</td> </tr> <tr style="height:14.25pt" height="19"> <td class="xl65" style="height:14.25pt;font-size:11.0pt;color:black; font-weight:400;text-decoration:none;text-underline-style:none;text-line-through: none;font-family:Arial;border-top:.5pt solid white;border-right:.5pt solid white; border-bottom:.5pt solid white;border-left:none;background:#DCE6F1; mso-pattern:#DCE6F1 none" height="19">1</td> <td class="xl65" style="font-size:11.0pt;color:black;font-weight:400; text-decoration:none;text-underline-style:none;text-line-through:none; font-family:Arial;border:.5pt solid white;background:#DCE6F1;mso-pattern: #DCE6F1 none">FLOWERS</td> <td class="xl65" style="font-size:11.0pt;color:black;font-weight:400; text-decoration:none;text-underline-style:none;text-line-through:none; font-family:Arial;border-top:.5pt solid white;border-right:none;border-bottom: .5pt solid white;border-left:.5pt solid white;background:#DCE6F1;mso-pattern: #DCE6F1 none">Lily</td> </tr> <tr style="height:14.25pt" height="19"> <td class="xl65" style="height:14.25pt;font-size:11.0pt;color:black; font-weight:400;text-decoration:none;text-underline-style:none;text-line-through: none;font-family:Arial;border-top:.5pt solid white;border-right:.5pt solid white; border-bottom:.5pt solid white;border-left:none;background:#B8CCE4; mso-pattern:#B8CCE4 none" height="19">2</td> <td class="xl65" style="font-size:11.0pt;color:black;font-weight:400; text-decoration:none;text-underline-style:none;text-line-through:none; font-family:Arial;border:.5pt solid white;background:#B8CCE4;mso-pattern: #B8CCE4 none">DOGS</td> <td class="xl65" style="font-size:11.0pt;color:black;font-weight:400; text-decoration:none;text-underline-style:none;text-line-through:none; font-family:Arial;border-top:.5pt solid white;border-right:none;border-bottom: .5pt solid white;border-left:.5pt solid white;background:#B8CCE4;mso-pattern: #B8CCE4 none">German shephered</td> </tr> <tr style="height:15.0pt" height="20"> <td class="xl65" style="height:15.0pt;font-size:11.0pt;color:black; font-weight:400;text-decoration:none;text-underline-style:none;text-line-through: none;font-family:Arial;border-top:.5pt solid white;border-right:.5pt solid white; border-bottom:.5pt solid white;border-left:none;background:#DCE6F1; mso-pattern:#DCE6F1 none" height="20">2</td> <td class="xl65" style="font-size:11.0pt;color:black;font-weight:400; text-decoration:none;text-underline-style:none;text-line-through:none; font-family:Arial;border:.5pt solid white;background:#DCE6F1;mso-pattern: #DCE6F1 none">DOGS</td> <td class="xl65" style="font-size:11.0pt;color:black;font-weight:400; text-decoration:none;text-underline-style:none;text-line-through:none; font-family:Arial;border-top:.5pt solid white;border-right:none;border-bottom: .5pt solid white;border-left:.5pt solid white;background:#DCE6F1;mso-pattern: #DCE6F1 none">Bulldog</td> </tr> <tr style="height:14.25pt" height="19"> <td class="xl65" style="height:14.25pt;font-size:11.0pt;color:black; font-weight:400;text-decoration:none;text-underline-style:none;text-line-through: none;font-family:Arial;border-top:.5pt solid white;border-right:.5pt solid white; border-bottom:.5pt solid white;border-left:none;background:#B8CCE4; mso-pattern:#B8CCE4 none" height="19">3</td> <td class="xl65" style="font-size:11.0pt;color:black;font-weight:400; text-decoration:none;text-underline-style:none;text-line-through:none; font-family:Arial;border:.5pt solid white;background:#B8CCE4;mso-pattern: #B8CCE4 none">AUTO</td> <td class="xl65" style="font-size:11.0pt;color:black;font-weight:400; text-decoration:none;text-underline-style:none;text-line-through:none; font-family:Arial;border-top:.5pt solid white;border-right:none;border-bottom: .5pt solid white;border-left:.5pt solid white;background:#B8CCE4;mso-pattern: #B8CCE4 none">3Star Auto</td> </tr> <tr style="height:14.25pt" height="19"> <td class="xl65" style="height:14.25pt;font-size:11.0pt;color:black; font-weight:400;text-decoration:none;text-underline-style:none;text-line-through: none;font-family:Arial;border-top:.5pt solid white;border-right:.5pt solid white; border-bottom:.5pt solid white;border-left:none;background:#DCE6F1; mso-pattern:#DCE6F1 none" height="19">3</td> <td class="xl65" style="font-size:11.0pt;color:black;font-weight:400; text-decoration:none;text-underline-style:none;text-line-through:none; font-family:Arial;border:.5pt solid white;background:#DCE6F1;mso-pattern: #DCE6F1 none">AUTO</td> <td class="xl65" style="font-size:11.0pt;color:black;font-weight:400; text-decoration:none;text-underline-style:none;text-line-through:none; font-family:Arial;border-top:.5pt solid white;border-right:none;border-bottom: .5pt solid white;border-left:.5pt solid white;background:#DCE6F1;mso-pattern: #DCE6F1 none">5Star Auto</td> </tr> <tr style="height:14.25pt" height="19"> <td class="xl65" style="height:14.25pt;font-size:11.0pt;color:black; font-weight:400;text-decoration:none;text-underline-style:none;text-line-through: none;font-family:Arial;border-top:.5pt solid white;border-right:.5pt solid white; border-bottom:none;border-left:none;background:#B8CCE4;mso-pattern:#B8CCE4 none" height="19">3</td> <td class="xl65" style="font-size:11.0pt;color:black;font-weight:400; text-decoration:none;text-underline-style:none;text-line-through:none; font-family:Arial;border-top:.5pt solid white;border-right:.5pt solid white; border-bottom:none;border-left:.5pt solid white;background:#B8CCE4; mso-pattern:#B8CCE4 none">AUTO</td> <td class="xl65" style="font-size:11.0pt;color:black;font-weight:400; text-decoration:none;text-underline-style:none;text-line-through:none; font-family:Arial;border-top:.5pt solid white;border-right:none;border-bottom: none;border-left:.5pt solid white;background:#B8CCE4;mso-pattern:#B8CCE4 none">6Star Auto</td> </tr> </tbody></table>

Thank you
&
Regards,
Zaska
 
Upvote 0
Zaska,


Sample raw data before the macro:


Excel Workbook
ABCDE
11 FlOWERS
2Rose
3Jasmin
4Tulip
5Lily
6
72 DOGS
8German shephered
9Bulldog
10
113 Auto
123Star Auto
135Star Auto
146Star Auto
15
Sheet1





After the macro:


Excel Workbook
ABCDE
11 FlOWERS1FlOWERSRose
2Rose1FlOWERSJasmin
3Jasmin1FlOWERSTulip
4Tulip1FlOWERSLily
5Lily2DOGSGerman shephered
62DOGSBulldog
72 DOGS3Auto3Star Auto
8German shephered3Auto5Star Auto
9Bulldog3Auto6Star Auto
10
113 Auto
123Star Auto
135Star Auto
146Star Auto
15
Sheet1





1. Is the second screenshot format/structure in columns C, D, and E, correct?

2. If the output in columns C, D, and E, is correct I can adjust the macro to delete columns A and B. Do you want columns A and B deleted?
 
Upvote 0
Hello,

Yes the output is correct and i made two changes to the code. But i am unsuccesful in changing the number format of Column C which will change to Column A after deleting the original Columns A:B.

Code:
Option Explicit
Sub SplitAV3()
' hiker95, 04/09/2011
' http://www.mrexcel.com/forum/showthread.php?t=542144
Dim AArea As Range, Sp, s As Long, NR As Long
Application.ScreenUpdating = False
Columns("C:E").ClearContents
NR = 1
For Each AArea In Range("A1", Range("A" & Rows.Count).End(xlUp)).SpecialCells(xlCellTypeConstants).Areas
  With AArea
    Sp = Split(Cells(.Row, 1), " ")
    s = .Row + .Rows.Count - 1 - .Row
    Range("C" & NR).Resize(s, 2).Value = Sp
    Range("E" & NR).Resize(s).Value = Range("A" & .Row + 1 & ":A" & .Row + .Rows.Count - 1).Value
    NR = Range("C" & Rows.Count).End(xlUp).Offset(1).Row
  End With
Next AArea
Columns("A:B").Delete
[COLOR=Red]Columns("A").NumberFormat = "0"[/COLOR]
Columns("C:E").AutoFit
Application.ScreenUpdating = True
End Sub

Thank you
 
Upvote 0
Give this macro a try...

Code:
Sub TransposeData()
  Dim Categories As Range, A As Range, Parts() As String
  Set Categories = Columns("A").SpecialCells(xlConstants)
  Application.ScreenUpdating = False
  On Error Resume Next
  For Each A In Categories.Areas
    Parts = Split(A(1).Value, " ", 2)
    A(1).Offset(, 2).Value = Parts(0)
    A(1).Offset(, 3).Value = Parts(1)
    A(1).Offset(, 4).Resize(A.Rows.Count - 1).Value = A(1).Offset(1).Resize(A.Rows.Count - 1).Value
  Next
  For Each A In Range("E1:E" & Cells(Rows.Count, "E").End(xlUp).Row).SpecialCells(xlCellTypeBlanks).Areas
    A.Offset(, -2).Resize(, 3).Delete xlShiftUp
  Next
  With Range("C1:D" & Cells(Rows.Count, "E").End(xlUp).Row)
    .SpecialCells(xlCellTypeBlanks).FormulaR1C1 = "=r[-1]C"
    .Value = .Value
  End With
  Application.ScreenUpdating = True
End Sub
 
Upvote 0

Forum statistics

Threads
1,223,716
Messages
6,174,069
Members
452,542
Latest member
Bricklin

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top