• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Code snippet activesheet

Hi,

Can anyone please provide a VBA code snippet to return to the activesheet where I actually click macrobutton.

In elaborate, I have an automation to run in various sheets but I need to have this clicked in 5 various sheets. If I click macrobutton in sheet1, that should activate the activesheet at the end of the automation and wiseverse.

Any help?

Thanks,
Karthik
 
Hi Karthik,

If my understanding is correct, once the automation is completed, you want to return to the sheet1. Am I correct? Else pls upload a sample file.
 
surround your macro code with a couple of lines:
Code:
Sub theMacro()
Set OrigSheet = ActiveSheet
'your current macro code
OrigSheet.Activate
End Sub
 
Tharhik

It is most unlikely that you would need to leave the sheet you are clicking the button on. The macro recorder will follow the mouse clicks around repeating your actions. It does not mean VBA has to act like this. You can almost do everything you need to on the active sheet without the screen flicker from selecting different sheets.

Happy to look at your code to show you how to do this.

Take care

Smallman
 
Back
Top