在单独的单元格中返回输出 [英] Return output in separate cells
本文介绍了在单独的单元格中返回输出的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我写过这个
任何想法如何解决这个问题?
解决方案
我还没有检查你的完整代码,但是这样可能会起作用:
对于v = LBound(vLOCs)To(UBound(vLOCs) - 1)
my_Travels = Left(Loc。单元格(vLOCs(v,2),1),Len(Loc.Cells(vLOCs(v,2),1)) - 2)
my_Travels.Offset(0,1)= Left(Loc.Cells vLOCs(v + 1,2),1),Len(Loc.Cells(vLOCs(v + 1,2),1)) - 2)
下一个v
假设 my_Travels
是一个单元格引用,然后 offset(0,1)
简单地引用下一列中的单元格。
I have written this User Defined Function code with the help of user @Jeeped.
I need to change two things in this code:
- That the output must be returned in the respective cells instead of all output being returned in one cell
- "From" and "To" output must is returned in separate columns.
This is the Current output:
Desirable output e.g:
I have tried to change this part of the code but without success:
'concatenate the locations from the array
For v = LBound(vLOCs) To (UBound(vLOCs) - 1)
sTMP = sTMP & "From " & loc.Cells(vLOCs(v, 2), 1) & " to " & loc.Cells(vLOCs(v + 1, 2), 1) & "; "
Next v
'truncate the string and return it
sTMP = Left(sTMP, Len(sTMP) - 2)
my_Travels = sTMP
The complete code can be found here
Any idea how I can solve this?
解决方案
I haven't reviewed your full code but something like this may work:
For v = LBound(vLOCs) To (UBound(vLOCs) - 1)
my_Travels = Left(Loc.Cells(vLOCs(v, 2), 1), Len(Loc.Cells(vLOCs(v, 2), 1)) - 2)
my_Travels.Offset(0, 1) = Left(Loc.Cells(vLOCs(v + 1, 2), 1), Len(Loc.Cells(vLOCs(v + 1, 2), 1)) - 2)
Next v
Assuming my_Travels
is a cell reference then offset(0, 1)
simply references the cell in the next column along.
这篇关于在单独的单元格中返回输出的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文