先生,我在Excel工作表的不同行的列中有一组类似的值,例如: ABC公司,ABC公司,ABC Comp。,ABC Com。我希望将这些类似的值转换为一个值
答案 0 :(得分:0)
不确定你到底需要什么,但这是一个启动者:
此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