【发布时间】:2021-05-21 18:09:41
【问题描述】:
在 JAVA 或 C++ 中,我们可以按照myString.insert(position, word) 的方式做一些事情。有没有办法在 Excel VBA 的字符串中做同样的事情?在我的工作表中,我有一个如下所示的字符串:01 / 01 / 995,我想在年份中插入 1,所以将其设为 01 / 01 / 1995。
Dim test_date As String
test_date = "01 / 25 / 995"
test_date = Mid(test_date, 1, 10) & "1" & Mid(test_date, 11, 4)
还有其他更简单/更优雅的方法吗?
【问题讨论】:
-
使用
Mid$而不是Mid,前者是字符串函数,后者是变体函数。字符串函数更快