问题描述:
脚本控制没两个数据换一行
解决方法:
您的脚本代码中并没有控制每两个换一行,您只需要做一个判断,每次增2之后,加一个换行符即可,下面是我修改后的代码:
- Function ProcessData(a As String, b As String) As String
- Dim arrA() As String
- arrA = Split(a, ";")
- Dim result As String
- result = ""
- ' 遍历数组B中的每个元素
- Dim i As Integer
- i = 0
- For Each itema As String In arrA
- If itema = b Then
- result = result & itema & "■ "
- Else
- result = result & itema & "□ "
- End If
- If i Mod 2 = 1 Then
- result = result & vbCrLf ' 添加换行符
- End If
- i = i + 1
- Next
- ' 去掉最后一个逗号
- result = Left(result, Len(result))
- ' 返回结果
- ProcessData = result
- End Function
复制代码 实现效果如下:
|