С помощью этого кода я пытаюсь найти ячейки в столбце, где есть запятая, и разделить его на 2 новые ячейки.
Далее я хочу Удалить исходную строку, но это кажется невозможным, поскольку значение используется в операции FindNext .
Что у меня есть:
Column D Column E
Carrot Vegetable
Apple,Banana Fruit
Что мне нужно:
Column D Column E
Carrot Vegetable
Apple Fruit
Banana Fruit
Что я сделал:
Sub newentry()
'
' newentry Macro
'
Dim line
Dim col
Dim content
With Sheets("Feuil3").Columns("D")
Set c = .Find(",", LookIn:=xlValues)
If Not c Is Nothing Then
firstAddress = c.Address
Do
c.Select
line = ActiveCell.Row
col = ActiveCell.Column
content = ActiveCell
category = Cells(line, "E")
Dim Table() As String
Dim i As Integer
'split content in a table
Table = Split(content, ",")
'loop on table
For i = 0 To UBound(Table)
'copy result on next line
Rows(line + 1).Insert
Tableau(i) = Application.WorksheetFunction.Trim(Table(i))
Cells(line + 1, col).Value = Table(i)
Cells(line + 1, "E").Value = category
Next i
Set c = .FindNext(c)
If c Is Nothing Then
GoTo DoneFinding
End If
'where/how to do this ?
Rows(c.Row).Delete Shift:=xlUp
Loop While Not c Is Nothing And c.Address <> firstAddress
End If
DoneFinding:
End With
End Sub
Как я могу удалить только что найденную строку?
Спасибо.