vba - VBA 中的动态变量

标签 vba excel dynamic formula quotes

我有这个 VBA 脚本,但我不知道如何使粗体部分动态化,因此公式为 =StripAccent(C2), =StripAccent(C3) 对每个 i 依此类推。

For i = 2 To 10  
    Cells(i, 5) = "=StripAccent(Ci)"
Next i

我读到过双引号,但它在那里不起作用。

最佳答案

这是一个可能的解决方案:

Public Sub TestMe()
    Dim i    As Long
    For i = 2 To 10
        Cells(i, 5) = "=StripAccent(C" & i & ")"
    Next i
End Sub

另一种是使用Cells(i,3)

编辑:如果您使用此处的自定义函数 - Converting Special Characters into alphabet那么这样的东西也可以工作(但不是公式):

Public Sub TestMe()
    Dim i    As Long
    For i = 2 To 10
        Cells(i, 5) = StripAccent(Cells(i,3))
    Next i
End Sub

关于vba - VBA 中的动态变量,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45432933/

相关文章:

arrays - 将多个单元格范围值分配给变量

caching - Symfony2 动态路由 - 缓存问题

动态改变端点 Camel

excel - VBA Excel : Local variables stored in memory?

vba - 无法使用 VBA 粘贴到合并单元格中

vba - 为什么我无法将 PowerPoint 图表分配给 VBA 中的图表变量?

python - 如何使用 python win32com.client 在 Excel 中添加折线?

excel - 如何在最后一个下划线之后提取Excel中字符串的最后一部分

excel - 自动在多个 Excel 文件中创建图表?

C - 分配动态数组后无法接受输入