VBA: How to get the last used cell by VBA code when the last error occured in a Workbook/Worksheet?

后端 未结 3 1395
情深已故
情深已故 2020-12-18 06:15

Eventually, I want to move the cell to the location where the last error occured. Edit: Forgot to say that I\'m using Excel 2003.

3条回答
  •  暗喜
    暗喜 (楼主)
    2020-12-18 06:58

    Wrap your VBA function in another function that stores the cell location and value as variants. Keep this 'wrapper' function as basic as possible so it won't cause any additional errors.

    If you're trying to debug app-crashing errors, the wrapper function could even store those values in a comma-delimited text file. Once stored, Excel can crash all it wants and you'll still know what the cell location and value were since you stored them outside of Excel beforehand.

提交回复
热议问题