excel - 使用时间格式和一般格式连接/组合列
问题描述
我被一个问题困住了,找不到解决方案。我想用两种不同的格式连接单元格。一个单元格的格式为“tt:mm”,另一个单元格的格式为“general”我将如何连接这些单元格?我在网上看到这可以在 Exel 中用类似的东西完成
=A1 & TEXT(B1,"tt:mm")
或 =CONCATENATE(TEXT(A1;"tt:mm"); " ";B1)
但是这是如何通过循环在 VBA 中完成的呢?
我试图将单元格添加在一起,但我没有以我想要的格式返回日期。
Sub Merge()
Dim i As Long
Dim time As String
LastRow = Range("A" & StartRow).End(xlDown).Row
For i = StartRow To LastRow
Range("B" & i).Value = Range("B" & i).Value & " " & Range("A" & i).Value
Range("B" & i).NumberFormat = "tt:mm General"
End Sub
因此,如果我为 xyz 和 02:30 运行此代码,那么我得到 0,15625 xyz 但我想得到 02:30 xyz。
非常感谢您的帮助。
解决方案
制作这一行:
Range("B" & i).Value = Range("B" & i).Value & " " & Range("A" & i).Value
进入:
Range("B" & i).Value = format(Range("B" & i).Value, "hh:mm") & " " & Range("A" & i).Value
推荐阅读
- sql - 在 BigQuery 中更新分区表和聚簇表
- jquery - 如何使用来自 jquery 加载的返回值和回调函数中的变量值相同的 jquery 加载?
- docker - 如何将 jupyter/all-spark-notebooks 容器与 docker 中的 hadoop 多节点集群连接起来
- python - 使用条件替换列表中的字符串
- c# - 找不到资源文件c#的路径
- gitlab - 将项目从我的用户名转移到我的组织后,我的用户名显示我是维护者而不是所有者
- apache-spark - 我们如何在数据框中有两行具有相同 id 的行?
- python - 通过终端在 openSUSE Leap 中安装 Python
- perl - 在 linux 中使用 perl 删除单元格(电子表格)中的换行符/新行
- php - Android 和 Laravel 相关问题