Last item in row, break to new row

2Ruff4U

New Member
Joined
May 27, 2004
Messages
31
Office Version
  1. 365
Platform
  1. Windows
Hello, and thank you for reviewing:
I have thousands of rows of data with a dollar amount (in text) at the end of the row. I need to "break" the amount to a new row, example follows. Thoughts on how to do this?
Many thanks

Before:
6466861 Name Address Buffalo NY 14206 First Last 85.33
6467271 Name Address Rochester NY 14611 First Last 13.22
6467633 Name Address Akron NY 14001 First Last 506.78

After:
6466861 Name Address Buffalo NY 14206 First Last
85.33
6467271 Name Address Rochester NY 14611 First Last
13.22
6467633 Name Address Akron NY 14001 First Last
506.78
 

Excel Facts

Highlight Duplicates
Home, Conditional Formatting, Highlight Cells, Duplicate records, OK to add pink formatting to any duplicates in selected range.
Not sure where you wanted the results. This puts them in column B.

Code:
Sub Break_Rows()
  Dim a As Variant, b As Variant, bits As Variant
  Dim i As Long, ub As Long
  
  a = Range("A2", Range("A" & Rows.Count).End(xlUp)).Value
  ReDim b(1 To UBound(a) * 2, 1 To 1)
  For i = 1 To UBound(a)
    bits = Split(a(i, 1))
    ub = UBound(bits)
    b(i * 2, 1) = Val(bits(ub))
    bits(ub) = vbNullString
    b(i * 2 - 1, 1) = RTrim(Join(bits))
  Next i
  Range("B2").Resize(UBound(b)).Value = b
End Sub

My sample data & results:


Book1
AB
1Before:
26466861 Name Address Buffalo NY 14206 First Last 85.336466861 Name Address Buffalo NY 14206 First Last
36467271 Name Address Rochester NY 14611 First Last 13.2285.33
46467633 Name Address Akron NY 14001 First Last 506.786467271 Name Address Rochester NY 14611 First Last
513.22
66467633 Name Address Akron NY 14001 First Last
7506.78
Sheet1
 
Upvote 0
Assuming the same layout that Peter used in Message #2 , and as long as you have less than 32,769 rows of original data, here is another macro that you can consider...
Code:
[table="width: 500"]
[tr]
	[td]Sub MoveLastValueToRowOfItsOwn()
  With Range("A2", Cells(Rows.Count, "A").End(xlUp))
    .Offset(, 1).Resize(2 * .Rows.Count) = Application.Transpose(Split(Join(Application.Transpose(Evaluate(Replace("IF({1},SUBSTITUTE(@,"" "",CHAR(1),LEN(@)-LEN(SUBSTITUTE(@,"" "",""""))))", "@", .Address))), Chr(1)), Chr(1)))
  End With
End Sub[/td]
[/tr]
[/table]
 
Last edited:
Upvote 0

Forum statistics

Threads
1,223,912
Messages
6,175,348
Members
452,638
Latest member
Oluwabukunmi

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