Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/vba/17.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_Vba - Fatal编程技术网

Excel 字符串值操作

Excel 字符串值操作,excel,vba,Excel,Vba,先生,我在Excel工作表的不同行的列中有一组类似的值,例如ABC公司、ABC公司、ABC公司、ABC公司。我希望将类似的值转换为一个值不确定您到底需要什么,但这是一个开始: 此VBA方法将在单元格上循环,计算值并将其打印到调试控制台,或使用该值设置另一个单元格 Sub concat() Dim rng As Range Dim row As Range Dim cell As Range Dim str As String Set rng = Ran

先生,我在Excel工作表的不同行的列中有一组类似的值,例如ABC公司、ABC公司、ABC公司、ABC公司。我希望将类似的值转换为一个值

不确定您到底需要什么,但这是一个开始:

此VBA方法将在单元格上循环,计算值并将其打印到调试控制台,或使用该值设置另一个单元格

Sub concat()

    Dim rng As Range
    Dim row As Range
    Dim cell As Range
    Dim str As String

    Set rng = Range("B3:B6")

    For Each row In rng.Rows
      For Each cell In row.Cells
        ' This is the result string:
        str = str & " " & cell.Value
      Next cell
    Next row

    ' Print the concatantion string to the console:
    Debug.Print (str)
    ' or just set the value in another cell:
    Cells(10, 10).Value = str
End Sub

你能用
字符制作一个伪excel表格吗?类似这样的内容:
ABC公司| ABC公司|……