我有一个大文件,它总结了几个工作簿,摘要文件中的链接每个月都会更新。] 1
每个月,文件路径中唯一更改的是日期。例如,我需要将所有单元格从“ WE 1.27.19”更改为“ WE 2.24.19”。通过查找和替换,我被提示通过进入公司的共享驱动器并单击新文件来单独更改单元格。
是否有一个宏可以自动执行此操作?
答案 0 :(得分:0)
如果主文件从未更改,也许:
Sub UpdateSomeLinks()
Dim wb As Workbook
Dim ws As Worksheet
Dim rngLinks As Range
Dim strDate As String
'sets variables
Set wb = myworkbook
Set ws = wb.Worksheets("myworksheet")
Set fd = Application.FileDialog(msoFileDialogFilePicker)
'input box for date
strDate = InputBox("Please type in new date")
'only loops through formula cells
For Each rngLinks In ws.UsedRange.SpecialCells(xlCellTypeFormulas)
rngLinks.Formula = Replace(rngLinks.Formula, "olddate", strDate)
Next rngLinks
'cleanup
Set ws = Nothing: Set wb = Nothing
Set rngLinks = Nothing: Set fs = Nothing
End Sub
然后,也许是工作表上的一个调用上述Sub的按钮。