How to merge rows so whole sheet shows “text” and “url” one under the other

jamescook

New Member
Joined
May 4, 2020
Messages
6
Office Version
  1. 2013
Platform
  1. Windows
There are a bunch of highlighted yellow text. I want to merge rows e.g. 6, 7, 8 and 9 into 6. Similarly 17 & 18 into 17. So and so forth

So the final output I want is

  1. Text
  2. URL
  3. Text
  4. URL
  5. Text
  6. URL

Note: 1. This is sample file but it could have hundreds of rows with uneven rows to be merged.

I have used the following formula ". =MOD(ROW(),2)" and then filter so only "Comments" shows then manually go through rows and merge manually. I want an automatic solution.
 

Attachments

  • Excel.png
    Excel.png
    91.5 KB · Views: 16

Excel Facts

What is the fastest way to copy a formula?
If A2:A50000 contain data. Enter a formula in B2. Select B2. Double-click the Fill Handle and Excel will shoot the formula down to B50000.
Try this, the results in column B

VBA Code:
Sub Merge_Rows()
  Dim i As Long, j As Long, a As Variant, b As Variant
  a = Range("A2", Range("A" & Rows.Count).End(3))
  ReDim b(1 To UBound(a), 1 To 1)
  j = 1
  For i = 1 To UBound(a)
    If LCase(Left(a(i, 1), 4)) <> LCase("http") Then
      b(j, 1) = b(j, 1) & a(i, 1) & Chr(10)
    Else
      If Right(b(j, 1), 1) = Chr(10) Then b(j, 1) = Left(b(j, 1), Len(b(j, 1)) - 1)
      j = j + 1
      b(j, 1) = a(i, 1)
      j = j + 1
    End If
  Next
  Range("B2").Resize(j, 1).Value = b
End Sub
 
Upvote 0
Hi DanteAmor,

Sorry for the late response.

Fantastic! It just works like a charm. Thanks a million. You are simply superb.
 
Upvote 0
I'm glad to help you. Thanks for the feedback.
 
Upvote 0

Forum statistics

Threads
1,214,870
Messages
6,122,021
Members
449,060
Latest member
LinusJE

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