Extract strings from cell and copy to rows below

Vlada

New Member
Joined
Jun 30, 2023
Messages
4
Office Version
  1. 365
Platform
  1. Windows
Dear experts,

If someone could help with problem i have, would be highly appreciated!

On picture1, column G, contains strings separated with ; that each, one by one, needs to be copied in rows below.
Number of rows is defined in column H.

Hope my question is clear, and the result needed is shown in Picture2.

Thanks in advance!
 

Attachments

  • Picture1.JPG
    Picture1.JPG
    25.9 KB · Views: 10
  • Picture2.JPG
    Picture2.JPG
    23.4 KB · Views: 10

Excel Facts

Spell Check in Excel
Press F7 to start spell check in Excel. Be careful, by default, Excel does not check Capitalized Werds (whoops)
Below what? Before where? Below where?

Complete the question then maybe I can answer.
 
Upvote 0
Welcome to the MrExcel board!

See if this does what you want.
Test with a copy of your data.

VBA Code:
Sub AdjustRows()
  Dim a As Variant, bits As Variant
  Dim i As Long, j As Long
  
  With Range("G2", Range("H" & Rows.Count).End(xlUp))
    a = .Value
    i = 1
    Do Until i > UBound(a)
      If a(i, 2) > 1 Then
        bits = Split(a(i, 1), ";")
        For j = 0 To UBound(bits)
          a(i + j, 1) = bits(j)
        Next j
      End If
      i = i + a(i, 2)
    Loop
    .Value = a
  End With
End Sub

Before:

Vlada.xlsm
ABCDEFGH
1ataAsRtTYUIYtFVNR
2abvcxtasd;sdr;erty3
3abvcxtasd;sdr;erty3
4abvcxtasd;sdr;erty3
5abvcxuasd;sdr2
6abvcxuasd;sdr2
7abvcxuasd1
Sheet1


After:

Vlada.xlsm
ABCDEFGH
1ataAsRtTYUIYtFVNR
2abvcxtasd3
3abvcxtsdr3
4abvcxterty3
5abvcxuasd2
6abvcxusdr2
7abvcxuasd1
Sheet1
 
Upvote 1
Solution
Hi Peter,

Thanks for welcome, I am happy to join this community of excel masters :).

The solution works PERFECTLY, it is exactly what i need!

Thank you countless times for your precious support!
 
Upvote 0
You are very welcome. Thanks for the follow-up. :)
 
Upvote 0

Forum statistics

Threads
1,215,376
Messages
6,124,594
Members
449,174
Latest member
chandan4057

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