How to activate specific excel sheet?

Get help with using AutoHotkey and its commands and hotkeys
Guest

How to activate specific excel sheet?

12 Apr 2015, 13:43

i want to activate sheet2 of current activated excel file. i.e. if current excel file say ABC is opened then i want that when i press hotkey f1 it should always activate sheet2 of ABC excel file...
how it is possible via com objects...
THANKS
HotKeyIt
Posts: 2269
Joined: 29 Sep 2013, 18:35
Contact:

Re: How to activate specific excel sheet?

12 Apr 2015, 13:47

Code: Select all

xl:=ComObjActive("Excel.Application")
xl.Sheets("Sheet2").Select
You can simply create a macro in Excel and check the code that is run when you do things ;)
nik2502
Posts: 3
Joined: 15 Jun 2020, 09:00

Re: How to activate specific excel sheet?

07 Aug 2020, 04:08

HotKeyIt wrote:

Code: Select all

xl:=ComObjActive("Excel.Application")
xl.Sheets("Sheet2").Select
You can simply create a macro in Excel and check the code that is run when you do things ;)
What if the excel file is invisible, How do i select a specific sheet ?
User avatar
flyingDman
Posts: 900
Joined: 29 Sep 2013, 19:01

Re: How to activate specific excel sheet?

07 Aug 2020, 11:06

You can use xl.sheets(2).select or xl.sheets(3).activate. In most cases they are equivalent but you can select multiple sheets and then activate one of them (but not more than 1). You should be able to use select and activate when the Excel is not made visible.

Return to “Ask For Help”

Who is online

Users browsing this forum: Bing [Bot], mikeyww, MiM, PatMk, Smile_, Youri11 and 72 guests