在Excel列中分隔分组的项

在Excel列中分隔分组的项,excel,function,Excel,Function,我有一个长长的数据列表,以以下方式排列在一列中: miR-4782-5p miR-4740-3p miR-3173-5p miR-617/2340 miR-1260/1260b/1391 miR-4642 miR-1392 我需要将其转换为以下格式: miR-4782-5p miR-4740-3p miR-3173-5p miR-617 miR-2340 miR-1260 miR-1260b miR-1391 miR-4942 miR-1392 本质上,我只想将按括号分组的数据分开,并使其成

我有一个长长的数据列表,以以下方式排列在一列中:

miR-4782-5p
miR-4740-3p
miR-3173-5p
miR-617/2340
miR-1260/1260b/1391
miR-4642
miR-1392
我需要将其转换为以下格式:

miR-4782-5p
miR-4740-3p
miR-3173-5p
miR-617
miR-2340
miR-1260
miR-1260b
miR-1391
miR-4942
miR-1392
本质上,我只想将按括号分组的数据分开,并使其成为自己的项,同时继续向下列表


想法?

这段代码应该能满足您的需要

Sub SplitCellsAndExtend_Olddasgf()
'takes cells with inside line feeds and creates new row for each.
'reverses merge into top cell.

Dim strCell As String, lastRow As Long, i As Long, j As Long, sPrefix As String
Const sSplitOn As String = "/"

application.ScreenUpdating = False
lastRow = Cells(Rows.Count, 1).End(xlUp).Row

    For i = lastRow To 1 Step -1
        strCell = Cells(i, 1)
        j = 0

        Do While InStr(1, strCell, sSplitOn) > 0
            Rows(i + j + 1).Insert
            sPrefix = Left(strCell, InStr(strCell, "-"))
            strCell = Right(strCell, Len(strCell) - InStr(1, strCell, sSplitOn))
            Cells(i + j, 1) = Left(Cells(i + j, 1).Value, InStr(1, Cells(i + j, 1), sSplitOn) - 1)
            strCell = sPrefix & strCell
            Cells(i + j + 1, 1).Value = strCell
            j = j + 1
        Loop
    Next
application.ScreenUpdating = True
End Sub

我不熟悉VisualBasic,所以我没有尝试过这方面的任何东西。但是,我确实编写了一个函数,它使用两列并以一种低效的方式分隔项目,因为我仍然需要在每个集合后创建新行。如果使用函数不够方便,那么我认为您需要使用VBA。使用辅助列是否可以接受?是的,但是如果有一种方法可以不使用它们,那将是有利的。嗯,它似乎不运行?在活动工作表的A列工作,这就是您运行它的方式吗?您可以在宏模块中复制它,然后使用编辑器中的F5或工作表中的Alt+F8运行它。