1

这段代码在本地工作簿中完美运行,但我不知道如何(我在 SOF 上尝试了一些建议)让它在 Personal.xlsb 文件中运行。任何帮助深表感谢。
'这个宏在本地工作 - 需要让它在 Personal.xlsb 级别工作

'This macro works locally - need to get it to work at the Personal.xlsb level
Sub AdvLookupVals()

   Dim colA_Range As Range
   Dim rngLookupRange As Range
   Dim rngFoundRange As Range
   Dim wb As Workbook

  ThisWorkbook.Worksheets("Sheet1").Activate

   'when you do this, Lookup.xls becomes active and sets the range
   Set wb = Workbooks.Open("C:\Lists\Resource_Lookup.xlsx", True, True) ' open the source workbook, read only
   Set rngLookupRange = wb.Worksheets("Sheet1").Range("A1:A656")

   'Makes target workbook active again
    ThisWorkbook.Activate

   'Set rngFoundRange = wb.Worksheets("Sheet1").Range("A1:A653")
   'rngFoundRange.AdvancedFilter Action:=xlFilterInPlace, CriteriaRange:= '_   'hoping this would make the macro work in Personal.xlsb

       Range("A1:A653").AdvancedFilter Action:=xlFilterInPlace, CriteriaRange:= _
        rngLookupRange, Unique:=False                                               'rngLookupRange gets the criteria from above. .filters by name.

   'releases resources back to the system and close the other workbook
   Set rngLookupRange = Nothing
   wb.Close False ' close the source workbook without saving any changes
   Set wb = Nothing ' frees memory

 End Sub
4

0 回答 0