How to modify this script to only find and replace in a specific column?
如何修改此脚本,只在特定列中查找和替换?
Set xl = CreateObject("Excel.Application")
xl.Visible = True
Set wb = xl.Workbooks.Open("C:\Users\test.xlsx")
Set ws = wb.Sheets("Sheet1")
Set objRange = ws.Range("Q1").End(xlDown).Select
objRange.Replace "~*", ""
The current script gives an error on the Set objRange
line. Replacing *
in the entire sheet would interefere with formulas.
当前脚本在Set objRange行上给出一个错误。在整张纸上替换*将用公式表示。
1 个解决方案
#1
1
You're thinking too complicated. Just tell the Range
property that you want the entire Q
column and call the Replace
method directly on that Range
object:
你的想法太复杂了。只需告诉Range属性你想要整个Q列,并直接调用Range对象上的Replace方法:
ws.Range("Q:Q").Replace "~*", ""
#1
1
You're thinking too complicated. Just tell the Range
property that you want the entire Q
column and call the Replace
method directly on that Range
object:
你的想法太复杂了。只需告诉Range属性你想要整个Q列,并直接调用Range对象上的Replace方法:
ws.Range("Q:Q").Replace "~*", ""