Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/excel/28.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Excel 提取唯一的两位数字,并将唯一的非重复两位数字放在由管道分隔的下一列中_Excel_Split_Duplicates_Pipeline - Fatal编程技术网

Excel 提取唯一的两位数字,并将唯一的非重复两位数字放在由管道分隔的下一列中

Excel 提取唯一的两位数字,并将唯一的非重复两位数字放在由管道分隔的下一列中,excel,split,duplicates,pipeline,Excel,Split,Duplicates,Pipeline,我在A列的1000个单元格中有类似的输入,其中每个值都有前两个字符,后面跟一些数字,并且有多个管道分隔值,如下所示- 输入(A列) 单元格A1=US6690414B2 | US420416T | CN1256694C | CN1401109A | DE60137365D1 单元格A2=EP1346328A1 | EP1346328B1 | ES2320416T3 | JP2004516556A 单元格A3=US20071032A1 | NZ2002048970A1 所需输出 B1单元=US |

我在A列的1000个单元格中有类似的输入,其中每个值都有前两个字符,后面跟一些数字,并且有多个管道分隔值,如下所示-

输入(A列)

单元格A1=US6690414B2 | US420416T | CN1256694C | CN1401109A | DE60137365D1

单元格A2=EP1346328A1 | EP1346328B1 | ES2320416T3 | JP2004516556A

单元格A3=US20071032A1 | NZ2002048970A1

所需输出

B1单元=US | CN | DE

单元格B2=EP | ES | JP

单元格B3=美国|新西兰

PS-我已经检查了所有类似的问题,但之前没有回答过,因此提出了问题。提前谢谢

使用此代码

Sub main2()
    Dim strng As Variant

    With CreateObject("Scripting.Dictionary")
For Each cell In Columns(1),SpecialCells(xlCellTypeConstants) ... Next cell
        For Each strng In Split(Replace(cell, " ", ""), "|")
            .Item(Left(strng, 2)) = .Item(Left(strng, 2)) & "|" & strng & "|"
        Next
        Range("B1").Resize(,.count).Value = ".Items"
        With cell.Offset(,1).Resize(.Count)
            .Replace "||", "--"
            .Replace "|", ""
            .Replace "--", " | "
        End With
    End With
End Sub

这需要vba,您尝试过什么?请显示对解决方案进行编码的尝试,并解释您发现的错误。堆栈溢出不是me站点的代码。Sub main2()Dim strng作为拆分中每个strng的CreateObject(“Scripting.Dictionary”)的变量(替换(范围(“A1”)、“”、“”、“”)、和“|”)。Item(左(strng,2))=.Item(左(strng,2))&“|”&strng&“|”下一个范围(“A2”)。调整大小(.Count)。Value=Application.Transpose(.Items)的范围为(“A2”)。调整大小为(.Count)。替换“||”、”--“.Replace”、”.Replace“--”、“|”End With End With End With End sub我已经尝试过了。请在原始帖子中插入代码,并解释错误。不要在注释中添加代码。