将列中的元素转换为vba excel中的单个文本

假设中间有空白栏,中间可以有多于一个的空白栏,我怎样才能在vba excel中编码。

列中的项目:

尼斯
至
遇到
您。

因此,我正在寻找:

很高兴见到你。

正如所评论的,这是我写的一个连接Range值的函数。
它根据你在单元格中看到它的方式连接它。
我不完全确定,但如果我已经涵盖了所有的可能性,但你可以试试看。

Public Function CONCATPLUS(ref_value As Range, Optional delimiter As Variant) As String Dim cel As Range Dim refFormat As String, myvalue As String If ref_value.Cells.Count = 1 Then CONCATPLUS = CVErr(xlErrNA): Exit Function If IsMissing(delimiter) Then delimiter = " " For Each cel In ref_value refFormat = cel.NumberFormat Select Case TypeName(cel.Value) Case "Empty": myvalue = vbNullString Case "Date": myvalue = Format(cel, refFormat) Case "Double" If refFormat <> "General" Then myvalue = Format(cel, refFormat) Else myvalue = cel End If Case "Error" Select Case True Case cel = CVErr(xlErrDiv0): myvalue = "#DIV/0!" Case cel = CVErr(xlErrNA): myvalue = "#N/A" Case cel = CVErr(xlErrName): myvalue = "#NAME?" Case cel = CVErr(xlErrNull): myvalue = "#NULL!" Case cel = CVErr(xlErrNum): myvalue = "#NUM!" Case cel = CVErr(xlErrRef): myvalue = "#REF!" Case cel = CVErr(xlErrValue): myvalue = "#VALUE!" Case Else: myvalue = "#Error" End Select Case Else: myvalue = cel End Select If Len(myvalue) <> 0 Then If CONCATPLUS = "" Then CONCATPLUS = myvalue Else CONCATPLUS = CONCATPLUS & delimiter & myvalue End If End If Next End Function