split data

Jagathsinghangoth

New Member
Joined
Sep 8, 2016
Messages
16
i have to require the data in following type automatically

main data is 1st row

1011a12b15c18f
1111211dfdd1f2d2

<tbody>
</tbody>

required as follows
1011a
1012b
1015c
1018f
11112
1111dfd
11d12d2

<tbody>
</tbody>

pls suggest
 

Excel Facts

Why are there 1,048,576 rows in Excel?
The Excel team increased the size of the grid in 2007. There are 2^20 rows and 2^14 columns for a total of 17 billion cells.
Here is one way:
Code:
Sub MyCopyData()

    Dim src As Worksheet
    Dim dst As Worksheet
    Dim lr As Long
    Dim r As Long
    Dim lc As Long
    Dim rd As Long
    
    Application.ScreenUpdating = False
    
'   Set source and destination sheets
    Set src = Sheets("Sheet1")
    Set dst = Sheets("Sheet2")
    
'   Find last row with data in column A on source sheet
    lrow = src.Cells(Rows.Count, "A").End(xlUp).Row
    
    src.Activate
'   Loop through all data
    For r = 1 To lrow
'       Find last row with data on destination sheet
        If dst.Cells(1, "A") = "" Then
            rd = 1
        Else
            rd = dst.Cells(Rows.Count, "A").End(xlUp).Row + 1
        End If
'       Copy column A to column A
        src.Cells(r, "A").Copy dst.Cells(rd, "A")
'       Find last column with data in row
        lc = src.Cells(r, Columns.Count).End(xlToLeft).Column
'       Copy paste transpose rest of data
        src.Range(Cells(r, 2), Cells(r, lc)).Copy
        dst.Cells(rd, "B").PasteSpecial Transpose:=True
        Application.CutCopyMode = False
'       Fill in the rest of column A
        If lc > 2 Then
            Range(dst.Cells(rd + 1, "A"), dst.Cells(rd + lc - 2, "A")) = dst.Cells(rd, "A")
        End If
    Next r
    
    Application.ScreenUpdating = True
    
End Sub
 
Upvote 0
Another Option
Results on sheet2.
Code:
[COLOR="Navy"]Sub[/COLOR] MG16Jun14
[COLOR="Navy"]Dim[/COLOR] Rng [COLOR="Navy"]As[/COLOR] Range, Dn [COLOR="Navy"]As[/COLOR] Range, c [COLOR="Navy"]As[/COLOR] [COLOR="Navy"]Long,[/COLOR] R [COLOR="Navy"]As[/COLOR] Range
[COLOR="Navy"]Set[/COLOR] Rng = Range("A1").CurrentRegion
ReDim ray(1 To Rng.Count, 1 To 2)
[COLOR="Navy"]For[/COLOR] [COLOR="Navy"]Each[/COLOR] Dn [COLOR="Navy"]In[/COLOR] Rng.Rows
    [COLOR="Navy"]For[/COLOR] [COLOR="Navy"]Each[/COLOR] R [COLOR="Navy"]In[/COLOR] Dn.Cells
        [COLOR="Navy"]If[/COLOR] Not R.Value = Dn.Cells(1).Value And R.Value <> "" [COLOR="Navy"]Then[/COLOR]
            c = c + 1
            ray(c, 1) = Dn.Cells(1).Value
            ray(c, 2) = R
        [COLOR="Navy"]End[/COLOR] If
    [COLOR="Navy"]Next[/COLOR] R
[COLOR="Navy"]Next[/COLOR] Dn
Sheets("Sheet2").Range("A1").Resize(c, 2).Value = ray
[COLOR="Navy"]End[/COLOR] [COLOR="Navy"]Sub[/COLOR]
Regards Mick
 
Upvote 0

Forum statistics

Threads
1,214,921
Messages
6,122,280
Members
449,075
Latest member
staticfluids

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