Go to a specific sheet on excel
Posted: 06 Sep 2022, 12:49
Im writing a code that needs to change constantly from vairious excel sheets, i found this code to activate an specified sheet in the active book of excel.
My question is, how can i use a variable to change each sheet.
My idea was this code:
I got an error in the last line before return, i guess its only the way i want to introduce the variable bue i dont find thw way to do it correctly, i´ll be so gretfull if some one can help me.
Code: Select all
F1::
Xl := ComObjActive("Excel.Application") ;creates a handle to your currently active excel sheet
Xl.Sheets("Sheet1").Activate
return
My idea was this code:
Code: Select all
F2::
count=1
Xl := ComObjActive("Excel.Application") ;creates a handle to your currently active excel sheet
Xl.ActiveSheet.Range("b1").select
send ^c
#HotkeyModifierTimeout, 100
sleep 500
StringReplace, clipboard, clipboard, `r`n,, all
Tipo=%Clipboard%
WinActivate, PORMEM_ADE1
Xl := ComObjActive("Excel.Application") ;creates a handle to your currently active excel sheet
Xl.Sheets("%Tipo%").Activate
return