Pasting to specific Excel sheet Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
silvanpierce
Posts: 10
Joined: 23 Feb 2022, 12:41

Pasting to specific Excel sheet

Post by silvanpierce » 06 Jul 2022, 07:43

hello, all

I am trying to see if it is possible to paste data into a specific cell on a specific excel sheet.
so far I have figured out getting it into my active excel, on whatever sheet is active; but if it would be possible to paste something into
"Sheet 2" while I'm sitting in "Sheet 1"' that'd be a game changer. below is a snippet of how I am pasting currently

Code: Select all

ex := ComObjActive("Excel.application")                  
nwrw := ex.Range("B3")
clipboard := regexreplace(clipboard, "(\s+|,)")
ex.activesheet.range("B3").PasteSpecial(-4104)
return  
any help is appreciated!

User avatar
boiler
Posts: 16768
Joined: 21 Dec 2014, 02:44

Re: Pasting to specific Excel sheet  Topic is solved

Post by boiler » 06 Jul 2022, 08:15

Where you would have ActiveSheet, use Worksheets("Sheet 2") instead (assuming it really has a space between "Sheet" and "2" like you showed, which isn't Excel's default naming). It's more likely that it's actually "Sheet2".

silvanpierce
Posts: 10
Joined: 23 Feb 2022, 12:41

Re: Pasting to specific Excel sheet

Post by silvanpierce » 06 Jul 2022, 08:28

boiler wrote:
06 Jul 2022, 08:15
Where you would have ActiveSheet, use Worksheets("Sheet 2") instead (assuming it really has a space between "Sheet" and "2" like you showed, which isn't Excel's default naming). It's more likely that it's actually "Sheet2".
you have no idea how annoyed I am at how simple that was.. I must have tried 30 different iterations, never thought to add a "s" at the end of worksheet.
thank you so much!!

User avatar
boiler
Posts: 16768
Joined: 21 Dec 2014, 02:44

Re: Pasting to specific Excel sheet

Post by boiler » 06 Jul 2022, 08:43

You probably will find this Excel object model reference from Microsoft to be useful. The examples are in VBA, which are easily translated to AHK.

Post Reply

Return to “Ask for Help (v1)”