【问题标题】:Excel VBA: Changin concatenate, mid and find formulas to VBA codeExcel VBA:更改连接、中间和查找公式到 VBA 代码
【发布时间】:2016-12-01 06:56:11
【问题描述】:

我正在创建另一个 VBA,因为我需要从 excel 公式到 VBA 的值...

excel公式是

=CONCATENATE(MID(J11,1,FIND("_",J11,1)),"#.jpg")

我在 VBA 中使用 excel 宏记录的代码是...

ActiveCell.FormulaR1C1 = _

"=CONCATENATE(MID(RC[-1],1,FIND(""_"",RC[-1],1)),""#.jpg"")"

这在 excel 的 Activecell 中给出了值,但我需要 VBA 的变量中的值。

【问题讨论】:

  • 这里不需要 excel 公式,只需要 VBA 与 & 和 VBA 函数(如 Mid()InStr())以及对范围的引用。

标签: excel vba concatenation


【解决方案1】:

这是vba中的代码-

Dim str As String

str = Mid(Sheets("sheetname").Range("J11").Value, 1, Application.WorksheetFunction.Search("_", Sheets("sheetname").Range("J11").Value, 1)) & "#.jpg"

只需根据您的工作表更改工作表名称即可。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2023-03-05
    • 1970-01-01
    • 1970-01-01
    • 2013-06-10
    • 1970-01-01
    • 2017-08-11
    • 1970-01-01
    相关资源
    最近更新 更多