Excel - Highlighting (underlining) the active row

Post your working scripts, libraries and tools for AHK v1.1 and older
daywalker
Posts: 32
Joined: 18 Jun 2019, 01:37

Re: Excel - Highlighting (underlining) the active row

26 Jan 2021, 08:53

Hi Haichen,

to click through the splashimage (needed in very rare situations, eg. you select cell beyond screen) replace

Code: Select all

			Splashimage,, B W%Width% H%line% Y%y1% X%x% CW%color% ; create line only on change
with

Code: Select all

			Splashimage,, B W%Width% H%line% Y%y1% X%x% CW%color%, , , HLSplashImage ; create line only on change
			WinSet, ExStyle, 0x20, HLSplashImage
			WinSet, Transparent, 255, HLSplashImage
User avatar
Xeo786
Posts: 760
Joined: 09 Nov 2015, 02:43
Location: Karachi, Pakistan

Re: Excel - Highlighting (underlining) the active row

03 Feb 2021, 07:03

I am using following code for the same purpose, as I do not care about undo and redo

Code: Select all

#Persistent 
onexit, exitting

^a::
oExcel := ComObjActive("Excel.Application")
Sheet := oExcel.ActiveSheet
ComObjConnect(Sheet, Worksheet_Events)
return

esc::
exitapp

exitting:
oExcel.activecell.EntireColumn.Interior.ColorIndex := 0
oExcel.activecell.EntireRow.Interior.ColorIndex := 0
exitapp

class Worksheet_Events {
	SelectionChange(cell) {
		static Lastcell
		lastcell.EntireColumn.Interior.ColorIndex := 0
		lastcell.EntireRow.Interior.ColorIndex := 0
		cell.EntireColumn.Interior.ColorIndex := 35
		cell.EntireRow.Interior.ColorIndex := 36
		Lastcell := cell
	}
}
I have changed above code used transparent colored GUI to hightlight rows
you can highlight multiple rows with different sizes as far as your selection is one part
what I mean with one part is when you press ctrl and select multiple ranges
"When there is no gravity, there is absolute vacuum and light travel with no time" -Game changer theory
User avatar
haichen
Posts: 631
Joined: 09 Feb 2014, 08:24

Re: Excel - Highlighting (underlining) the active row

03 Feb 2021, 07:29

Nice. I'm sure there are users for it.

For me, undo and redo are prerequisites.
User avatar
Xeo786
Posts: 760
Joined: 09 Nov 2015, 02:43
Location: Karachi, Pakistan

Re: Excel - Highlighting (underlining) the active row

03 Feb 2021, 07:54

haichen wrote:
03 Feb 2021, 07:29
For me, undo and redo are prerequisites.
with second example you have the ability to redo and undo
"When there is no gravity, there is absolute vacuum and light travel with no time" -Game changer theory
User avatar
haichen
Posts: 631
Joined: 09 Feb 2014, 08:24

Re: Excel - Highlighting (underlining) the active row

03 Feb 2021, 08:22

Hi Xeo786,
that you can use a Class with ComObjConnect was new to me. Thank you.
It would be great if your script could switch to other Excel windows and the highlighting could move with the scrolling, as it does with my script.
dagonet
Posts: 1
Joined: 01 Apr 2024, 23:36

Re: Excel - Highlighting (underlining) the active row

03 Apr 2024, 12:25

Hi and thanks for the amazing script! I'm using it daily since installed.
I can confirm that I had to use burque505's amendments to make it work in Excel 16 under Windows 10, but now it works perfectly.

Wondering whether the script could be easily changed to keep the line visible also when Excel is no longer the active window?
(I tinkered a little, trying to comment out the IF-statement checking for if hwnd:=WinActive("ahk_class XLMAIN") but that just broke the script.)

Return to “Scripts and Functions (v1)”

Who is online

Users browsing this forum: Chunjee and 184 guests