【问题标题】:Looking for VBA equivalent for Strright寻找 Strright 的 VBA 等效项
【发布时间】:2020-01-14 04:04:20
【问题描述】:

寻找与 LotusScript 的 Strright 等效的 VBA。 sn-p 是将错误消息连接到一个单元格中。

LotusScript Strright

'Meera's error message code
ReDim Preserve errormsg(i)
errormsg(i) = "Field Required"
IsError = True

...
errormsg(i) = "Invalid Date"
etc...

If IsError = True Then
   tmpMsg = ""
   For Each v In errormsg
       tmpMsg = tmpMsg + "," + v
   Next v
   Cells(Row, 8).Value = strright(tmpMsg, ",")      'LotusScript
End If

【问题讨论】:

  • Instr()Mid()

标签: excel vba concatenation lotusscript


【解决方案1】:

您可以使用Join()

If IsError = True Then
   Cells(Row, 8).Value = Join(errormsg, ",")
End If

或者使用这个模式:

If IsError = True Then
   Dim sep
   tmpMsg = ""
   For Each v In errormsg
       tmpMsg = tmpMsg + sep + v
       sep = ","
   Next v
   Cells(Row, 8).Value = tmpMsg
End If

【讨论】:

    猜你喜欢
    • 2022-07-19
    • 1970-01-01
    • 1970-01-01
    • 2010-10-29
    • 1970-01-01
    • 2011-09-24
    • 2021-01-31
    • 1970-01-01
    • 2016-04-25
    相关资源
    最近更新 更多