Copying complex data format

Durga

Board Regular
Joined
Apr 22, 2007
Messages
117
Hi,

I have a set of data in the following format which I want to have in the simplified format as mentioned below on Sheet2.

Excel Workbook
ABCDEFGHI
1Sheet1
2ONMOB1230000
30904030790660570
4
5DASONMOB0001000
639142000
7
8OLDMCA0000
90000
10
11Sheet2
12
13ONMOB12300000904030790660570
14DASONMOB000100039142000
15OLDMCA00000000
16
Sheet1


Since the data volume is quite huge, can it possible to write a macro for this.
please help.

Thanks in Advance.
 

Excel Facts

Create a chart in one keystroke
Select the data and press Alt+F1 to insert a default chart. You can change the default chart to any chart type
Durga

See if this is what you want.

<font face=Courier New><SPAN style="color:#00007F">Sub</SPAN> Rearrange()
    <SPAN style="color:#00007F">Dim</SPAN> ws1 <SPAN style="color:#00007F">As</SPAN> Worksheet
    <SPAN style="color:#00007F">Dim</SPAN> ws2 <SPAN style="color:#00007F">As</SPAN> Worksheet
    <SPAN style="color:#00007F">Dim</SPAN> lr <SPAN style="color:#00007F">As</SPAN> <SPAN style="color:#00007F">Long</SPAN>
    <SPAN style="color:#00007F">Dim</SPAN> nr <SPAN style="color:#00007F">As</SPAN> <SPAN style="color:#00007F">Long</SPAN>
    
    Application.ScreenUpdating = <SPAN style="color:#00007F">False</SPAN>
    Application.EnableEvents = <SPAN style="color:#00007F">False</SPAN>
    <SPAN style="color:#00007F">Set</SPAN> ws1 = Sheets("Sheet1")
    <SPAN style="color:#00007F">Set</SPAN> ws2 = Sheets("Sheet2")
    lr = ws1.Range("A" & Rows.Count).End(xlUp).Row
    nr = 1
    <SPAN style="color:#00007F">For</SPAN> r = 1 <SPAN style="color:#00007F">To</SPAN> lr
        <SPAN style="color:#00007F">If</SPAN> <SPAN style="color:#00007F">Not</SPAN> (IsEmpty(ws1.Cells(r, 1))) <SPAN style="color:#00007F">Then</SPAN>
            <SPAN style="color:#00007F">With</SPAN> ws1.Cells(r, 1)
                .Resize(1, 5).Copy _
                    Destination:=ws2.Cells(nr, 1)
                .Offset(1, 1).Resize(1, 4).Copy _
                    Destination:=ws2.Cells(nr, 6)
                nr = nr + 1
            <SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">With</SPAN>
        <SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">If</SPAN>
    <SPAN style="color:#00007F">Next</SPAN> r
    Application.ScreenUpdating = <SPAN style="color:#00007F">True</SPAN>
    Application.EnableEvents = <SPAN style="color:#00007F">True</SPAN>
<SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">Sub</SPAN></FONT>
 
Upvote 0

Forum statistics

Threads
1,214,561
Messages
6,120,225
Members
448,951
Latest member
jennlynn

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