VBA - 在串联单元格之间插入空格

标签 vba excel ms-office

这段代码对我有用。但是,在目标单元格中​​,我希望 A2 和 B2 的值之间有一个空格:

For j = 1 To lastRow3
    If ws.Range("A" & j) = "OKUMA LATHE" Then
        Cells(j, lastCol2 + 2).Formula = "=$A2&$B2"
    End If
Next j

男孩该做什么?我尝试的所有操作都会出现编译错误...

最佳答案

您需要将 VBA 中的引号加倍

For j = 1 To lastRow3
    If ws.Range("A" & j) = "OKUMA LATHE" Then
        Cells(j, lastCol2 + 2).Formula ="=$A2 & "" "" & $B2"
    End If
Next j

关于VBA - 在串联单元格之间插入空格,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45765867/

相关文章:

VBA 错误 : Object variable or with variable not set

vba - Excel VBA根据单元格值插入行并根据该数字向下复制列

Linux命令行将pdf转excel

excel - 有没有办法开发自定义 SmartArt?

RegExp 不匹配 VBA 中的换行符

vba - If 或语句始终为真

excel - 运行时错误 '1004' : Unable to set the enabled property of the OLEObject class

Excel VBA : Is there a way to iterate through characters in a specific range?

java - Apache poi 单元格对角删除线

c# - 如何在服务器端使用 C# 创建 Excel 兼容的电子表格?