ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Loosing Cell Selection (https://www.excelbanter.com/excel-programming/289784-loosing-cell-selection.html)

Nick

Loosing Cell Selection
 
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?



Rob van Gelder[_4_]

Loosing Cell Selection
 
Nick: Let's see your code...

--
Rob van Gelder - http://www.vangelder.co.nz/excel


"Nick" wrote in message
...
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?





Bob Phillips[_6_]

Loosing Cell 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)

"Nick" wrote in message
...
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?





Harald Staff

Loosing Cell Selection
 
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.
--
HTH. Best wishes Harald
Followup to newsgroup only please.

"Nick" wrote in message
...
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?






All times are GMT +1. The time now is 07:45 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com