View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
Claus Busch Claus Busch is offline
external usenet poster
 
Posts: 3,872
Default Copy rows as many there are 'slashes' in the cell and split out the content of that cell in the copied rows

Hi Johan,

Am Sun, 22 Sep 2019 22:56:49 -0700 (PDT) schrieb JS SL:

How to mark the cell column F with the slashes 'green' (that are the one to be copied) and then the one that you splitted out and copied, the cell in column F 'yellow'.
Then it's easy to see which one was the basic (= green) and the copied/splitted ones (=yellow).


change the code to:

Sub CopyRows()
Dim rngC As Range
Dim varTmp As Variant
Dim LRow As Long, i As Long

Application.ScreenUpdating = False
With ActiveSheet
LRow = .Cells(.Rows.Count, "F").End(xlUp).Row
For i = LRow To 2 Step -1
If InStr(.Cells(i, "F"), "/") 0 Then
varTmp = Split(.Cells(i, "F"), "/")
.Cells(i, "F").Interior.Color = vbGreen
.Rows(i).Copy
.Rows(i + 1).Resize(UBound(varTmp) + 1).Insert shift:=xlDown
With .Cells(i + 1, "F").Resize(UBound(varTmp) + 1)
.Value = Application.Transpose(varTmp)
.Interior.Color = vbYellow
End With
End If
Next
End With
Application.ScreenUpdating = True
End Sub


Regards
Claus B.
--
Windows10
Office 2016