如何 return 到调用宏的工作表?

How to return to the worksheet a macro was called from?

我有一个宏,它在 3 个工作 sheet 上的按钮上重复,它在工作 sheet 之间移动,现在一旦宏命令完成,我将它设置为 return 到第 3 个 sheet 每次。 有没有我可以在代码中放入 return 视图 sheet 的视图,宏首先被激活而不是集合 sheet.

将活动 sheet 保存在一个变量中,然后,在您的宏完成后,再次 select 变量中的 sheet:

' at the start of your macro:
Dim sourceSheet as Worksheet
set sourceSheet = ActiveSheet


' at the end of your macro:
Call sourceSheet.Activate