View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Tom Ogilvy Tom Ogilvy is offline
external usenet poster
 
Posts: 27,285
Default Selected cells become deselected?

I think you would have to disable the event to do this

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
if application.CutCopyMode = True then exit sub
If blnSaving = True Then Call Check_Existing_Codes(Target)
cmbNewWorkCode.Visible = False
'more code here
End Sub

--
Regards,
Tom Ogilvy


"Bob Holmes" wrote in message
...
I'm using a worksheet as a front-end for some data entry. I have code in
the 'worksheet_selectionchange' event that enables/disables command

buttons
and comboboxes on the sheet based on the column in which the user places

the
cursor. I am finding that after selecting some cells for copying, that

the
selection goes away as soon as I reach code in this event that is related

to
the command button or any object on the worksheet, which means that there

is
nothing to paste.
Here is a sample of my code:

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If blnSaving = True Then Call Check_Existing_Codes(Target)
cmbNewWorkCode.Visible = False
'more code here
End Sub

I select cells, choose to copy the selection and then select the cell

where
it should paste. Upon selecting the cell for pasting, this routine is
triggered and the first line causes no problems since it is only checking
the value of a variable. Upon execution of the second line, the selection
disappears and the paste feature is disabled.
I'm certain that this is where I need to place this code, since I need to
know as soon as the user has selected a cell in order to determine where

the
cursor is. Is there some way to maintain the selection even though the

code
is working on objects on the sheet. Does anyone have any suggestions.

I'm
willing to try anything. Thanks for any help you can offer.
--
Bob Holmes