|
你试试,这个是按照你的要求,输入参数(b3,"\n")就能实现。
有个问题
这个公式不能放在同一行书写,不然会出现错误。即A3不能输入参数(b3,"\n"),只能再A4或者A2输入此参数。
我也不知道为什么。看看有没有大神能解决。
Function TxtJoin(rg As Range, Joinstr As String)
end_col = rg.End(2).Column
title1_arr = Cells(1, 1).Resize(1, end_col).Value
title2_arr = Cells(2, 1).Resize(1, end_col).Value
brr = Cells(rg.Row, 1).Resize(1, end_col).Value
text_1 = brr(1, 3) & Joinstr
text_1 = brr(1, 3) & Joinstr & "[基本项目]" & Joinstr & _
title2_arr(1, 2) & ":" & brr(1, 2) & Joinstr
For icol = 1 To UBound(title1_arr, 2)
If title1_arr(1, icol) = "基本项" Then
text_2 = text_2 & title2_arr(1, icol) & ":" & brr(1, icol) & Joinstr
End If
Next
text_3 = "[扣款项目]" & Joinstr
For icol = 1 To UBound(title1_arr, 2)
If title1_arr(1, icol) = "扣款项" Then
text_4 = text_4 & title2_arr(1, icol) & ":" & brr(1, icol) & Joinstr
End If
Next
text_5 = title2_arr(1, end_col) & ":" & brr(1, end_col) & Joinstr
text_ = text_1 & text_2 & text_3 & text_4 & text_5
TxtJoin = text_
End Function
|
|