excel - Highlight Row-Column of selected cell -


be gentle guys, i'm not programmer.

i got snippit of code off internet many many moons ago. give credit, don't remember came from.

sub worksheet_selectionchange(byval target excel.range) static xrow static xcolumn if xcolumn <> "" columns(xcolumn) .interior.colorindex = xlnone end with rows(xrow) .interior.colorindex = xlnone end end if prow = selection.row pcolumn = selection.column xrow = prow xcolumn = pcolumn columns(pcolumn) .interior.colorindex = 19 .interior.pattern = xlsolid end with rows(prow) .interior.colorindex = 19 .interior.pattern = xlsolid end end sub 

the above code highlights rows , columns of selected sell. problem highlights columns 1 1048576, causes vertical scroll bar tiny. plus if there color coding in spreadsheet screws up. decided write own highlighter. put border around selected row,column , 500 rows. works, almost. problem in code cancels copy command, , not allow me paste, did not happen in code above. copy/paste must. appreciated.

sub worksheet_selectionchange(byval target excel.range) range("a1:n500").borders(xledgeleft).weight = xlthin range("a1:n500").borders(xledgetop).weight = xlthin range("a1:n500").borders(xledgebottom).weight = xlthin range("a1:n500").borders(xledgeright).weight = xlthin range("a1:n500").borders(xlinsidevertical).weight = xlthin range("a1:n500").borders(xlinsidehorizontal).weight = xlthin range("a1:n500").borders(xledgeleft).color = vbblack range("a1:n500").borders(xledgetop).color = vbblack range("a1:n500").borders(xledgebottom).color = vbblack range("a1:n500").borders(xledgeright).color = vbblack range("a1:n500").borders(xlinsidevertical).color = vbblack range("a1:n500").borders(xlinsidehorizontal).color = vbblack dim splitaddress() string splitaddress = split(activecell.address, "$") dim rowselection string rowselection = "a" & splitaddress(2) & ":" & "n" & splitaddress(2) dim colselection string colselection = splitaddress(1) & "1" & ":" & splitaddress(1) & "500" range(rowselection) .borderaround weight:=xlthick, color:=rgb(255, 0, 0) end with range(colselection) .borderaround weight:=xlthick, color:=rgb(255, 0, 0) end end sub 

try this.

it work in progress

it copies format, default format, last cell in worksheet

the code uses no copy/paste borders

i still working on copy/paste between cells having trouble with

private sub worksheet_selectionchange(byval target range)      application.screenupdating = false      dim aaa displayformat     set aaa = range("xfd1048576").displayformat   ' copy format last cell (it cheat)      range("a1:n500").borders.color = aaa.borders.color          ' revert border color default     range("a1:n500").borders.linestyle = aaa.borders.linestyle      dim integer     = xledgeleft xledgeright   ' loop 4 outside borders (7 10)         target.entirerow.resize(1, 8).borders.item(i).color = vbred         target.entirerow.resize(1, 8).borders.item(i).weight = xlthick          target.entirecolumn.resize(500, 1).borders.item(i).color = vbred         target.entirecolumn.resize(500, 1).borders.item(i).weight = xlthick      next      application.screenupdating = true  end sub 

Comments

Popular posts from this blog

python Tkinter Capturing keyboard events save as one single string -

android - InAppBilling registering BroadcastReceiver in AndroidManifest -

javascript - Z-index in d3.js -