View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Dave Peterson Dave Peterson is offline
external usenet poster
 
Posts: 35,218
Default Cut and paste by reference part 2

Can you just break it at column E and column H?

Option Explicit
Sub DDDD2()
Dim i As Long
Dim lastrow As Long
Dim rng As Range
lastrow = Cells(Rows.Count, 1 _
).End(xlUp).Row
For i = lastrow + 1 To 2 Step -1
Set rng = Cells(i - 1, 1)
Rows(i).Resize(2).Insert
Cells(i - 1, 5).Resize(1, 3).Copy Cells(i, 1)
Cells(i - 1, 8).Resize(1, 3).Copy Cells(i + 1, 1)
Cells(i - 1, 5).Resize(1, 6).ClearContents
Next
End Sub

Lunks wrote:

As you can see on another thread, I had some problems making some cells
being cut down to another row.
(thread:
http://groups.google.com/group/micro...ecc6f058e0f01e)

Tom Ogilvy did a pretty nice job and made a script that did everything
I needed.

But now I need something else. I want to break more than one line,
like:

P|00000|ICMS|IPI|T|123|999|T|123|456
P|00001|ABCD|ASD|T|456|666|T|888|4456
P|00002|LINK|LUNK|T|789|333 |T|321|3214

Would become:

P|00000|ICMS|IPI
T|123|999
T|123|456
P|00001|ABCD|ASD
T|456|666
T|888|4456
P|00002|LINK|LUNK
T|789|333
T|321|3214

A proposal would be that every cell with just a "T" would be triggered
a new row.
Remembering that each "|" means a cell divider.

Thanks in advance specially to Tom Ogilvy, which did a great job.


--

Dave Peterson