Loosing Cell Selection

  • Thread starter Thread starter Nick
  • Start date Start date
N

Nick

In excel, I selected a cell or range of cells to copy, and
they highlighted, I have code that runs on OnKey event.
This code changes the color of a few cells.
Because of the coding for coloring the selection of cells
for copy are lost. Is there a way to preserve the original
cells from loosing focus and selection?
 
Nick

Set myRange = Selection
' do your thing

myRange.Select

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)
 
In 99% of the cases you don't have to move, select, activate anything at all, leaving your
current location intact and your operations invisible.

Run this in a 3-or-more sheet empty workbook, Sheet1 active, some cell selected:

Sub test()
Sheets(2).Range("C3:D6").Interior.ColorIndex = 3
Sheets(3).Range("C12").Value = "Kilroy was here"
Sheets(3).Range("C12").Interior.ColorIndex = 19
Sheets(3).Range("C12").Copy Sheets(2).Range("A1")
Sheets(2).Range("A2").Value = "You ran me from " & _
ActiveSheet.Name & "!" & Selection.Address
End Sub

All changes are in sheets 2 and 3.
 
Back
Top