Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 16
Default how to get address of source of copy (range with marquee a.k.a. "marching ants")

In the Worksheet_SelectionChange event, is there a way to determine
the range of cells currently highlighted with the marquee, given that
CutCopyMode is true?

The reason I'd like to know is that I am changing the Enable state of
a command button depending on the Target range (i.e. where the user is
placing the cursor); if in a certain range, the button is to be
enabled, otherwise it is to be disabled. The problem is that setting
the Enable property on the button clears the CutCopyMode state. This
breaks copy-paste functionality.

Since I already have a selection change event handler (for other
reasons), I intended to work around this issue by noting the source
range, changing the button state as required, reselecting the source
range, and then reactivating the Target. So instead of just:

btnAddRow.Enabled = enb ' set button state as req'd

I planned to instead do:

If btnAddRow.Enabled < enb Then ' if change req'd
If Application.CutCopyMode < 0 Then ' if marquee is up
Set r = Application.CutCopySourceRange ' get marquee range
btnAddRow.Enabled = enb ' set enable state
r.SetAsCopySource ' restore marquee
Target.Activate ' restore ActiveCell
Else
btnAddRow.Enabled = enb ' just set enable property as required
End If
End If

I would entertain alternatives. I thought about tracking the current
selection, but I'm not sure I can reliably determine the actual range
with the marquee that way.

Thanks
tbone
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
"Marching ants" around copied cell Riccol New Users to Excel 31 April 2nd 23 07:45 PM
=HYPERLINK("#"&CELL("address", ADDRESS(MATCH(VALUE(B3),Range ... ? sarah Excel Worksheet Functions 0 February 17th 09 02:06 PM
How to setup "marching ants" border Excel cell? OK in MS Word. NJDevil Excel Discussion (Misc queries) 3 January 31st 07 05:46 PM
how to get marching ants in Excel programmatically Dev Excel Programming 7 September 30th 06 12:22 AM
Marching ants news.microsoft.com[_8_] Excel Programming 3 July 22nd 05 06:40 PM


All times are GMT +1. The time now is 12:06 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"