#NAME? error in Excel for VBA Function

后端 未结 12 1082
耶瑟儿~
耶瑟儿~ 2020-12-31 01:01

I am making my first VBA program and trying to run the following function. The function checks a specific named range for the first row which does not have a value greater t

12条回答
  •  佛祖请我去吃肉
    2020-12-31 01:44

    This solution applies to users with an Excel installed in another language than "United States English": I had a similar problem when making a copy of the active workbook to duplicate it and immediately opened the copy afterwards:

    Non-working code:

       ThisWorkbook.SaveCopyAs NewFileName
       Set wb = Workbooks.Open(FileName:=NewFileName)
    

    This always showed me several cells with Error 2029 / "#NAME?". If I opened the Workbook "the official way" via the File-Menu it worked as expected.

    I solved the issue by adding the parameter "local:=true" to the open statement:

    Working code:

       ThisWorkbook.SaveCopyAs NewFileName
       Set wb = Workbooks.Open(FileName:=NewFileName, Local:=True)
    

    as VBA expected english function names in my German workbook. With this parameter VBA is told directly to use the local names.

    I hope that helps someone not to loose several hours, as I did...

提交回复
热议问题