|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
Sub 按表替换()
'首先引用ms excel
'运行前关闭所有excel程序
Dim ex As Excel.Application, boo As Excel.Workbook, shee As Worksheet, i As Integer
Set ex = New Excel.Application
Set boo = ex.Workbooks.Open("C:\Documents and Settings\Administrator\桌面\替换表.xls") '假如在桌面
ex.Visible = False '设置EXCEL对象可见(或不可见)
Set shee = boo.Worksheets(1) '设置活动工作表
With shee
For i = 1 To .Range("b65536").End(xlUp).Row
ActiveDocument.Content.Find.Execute findtext:=.Range("a" & i), replacewith:=.Range("b" & i), Replace:=wdReplaceAll, Forward:=True '将excelA列替换为B列内容
Next
End With
boo.Close
ex.Quit
Set boo = Nothing
Set ex = Nothing
End Sub
|
评分
-
1
查看全部评分
-
|