【发布时间】:2017-02-16 14:11:43
【问题描述】:
只是寻求以下代码块的帮助。我在这里要做的是将包含在字母中的静态变量替换为相应的值。
代码旨在循环遍历一个表,并且对于列 [Variable] 下的每一行,将该变量的任何实例替换为“blankLetter”中的实例。也许这不是实现这一目标的最佳方式...
Public Function letterReplace(blankLetter As String, letterArray As Dictionary) As String
'Lookup the variable table and for each variable replace the instance of that in the array
Application.ScreenUpdating = False
Dim row As Range
Dim temp As String
For Each row In [varTable[Variable]].Rows
'temp = "<PURVNAME>"
temp = row.Value
letterReplace = Replace(blankLetter, temp, letterArray(temp))
Next
Application.ScreenUpdating = True
End Function
以下工作正常:
letterReplace = Replace(blankLetter, "<PURVNAME>", letterArray("<PURVNAME>"))
但是这一行并没有替代任何东西:
letterReplace = Replace(blankLetter, temp, letterArray(temp))
我已经搜索过,但最终胜出。
任何帮助都会很棒。
标记
【问题讨论】:
-
您最好展示一些数据示例。