[英]How to replace regular text in Excel into HTML unordered list (for export to CSV)?
如何将Excel工作表中的特定列转换为HTML无序列表? 做到这一点:
Item 1
Item 2
Item 3
至:
<ul>
<li>Item 1</li>
<li>Item 2</li>
<li>Item 3</li>
</ul>
我已经在网上搜索了,甚至在解决方案附近都找不到任何东西。
假设数据在另一列中的ColumnA中:
="<li>"&A1&"</li>"
复制到适合的位置,在顶部添加<ul>
,在底部添加<ul>
</ul>
,选择另一列“复制”,“选择性粘贴”,“顶部的值”,然后删除ColumnA。
如果将其添加到新模块中,则可以像公式一样使用它,指定要转换为列表的范围,这可能无法正常工作。
例如: =getUnorderedList(A1:A10)
-您将无法使用A:A
类型引用来将整列用作其当前编写的内容。
Public Function getUnorderedList(ByRef Target As Range) As String
Dim Result As String: Result = ""
Dim Cell As Variant
For Each Cell in Target.Cells
Result = Result & "<li>" & Cell.Value & "</li>" & vbNewLine
Next Cell
getUnorderedList = "<ul>" & vbNewLine & Result & "</ul>"
End Function
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.