Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 22
Default Remember SelectionChange range in the Change sheet event?

Hi,

In the Worksheet_Change event, I evaluate with Intersect method where the
change take place. If not intersect is nothing, then I need to change format
in the cells BEFORE (the earlier selection). I guess I can do this if I can
"store" the Worksheet_SelectionChange Target.address and pick it up in the
Worksheet_Change event.

I don't want to store it as a temporary txt file, but solve the problem into
the VBA. How can this be done? If it can't with this approach, does anybody
know a better one?

/Kind Regards


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,163
Default Remember SelectionChange range in the Change sheet event?

Do you need to store it if the file is saved, or only while the file is open?

If only while open, insert a module in VBA and use it to create a public
object variable of type Range:

Public StoreSelection as Range

Then, in your event procedu
Set StoreSelection = Target

If you need to store this range (by the address) between sessions (i.e. even
when the book is closed) you can't do it simply in VBA since your VBA code
will necessarily be shut down when you leave Excel - but instead of a text
file, why not store it in the actual workbook? You could create a hidden
sheet (I'll call it SaveAddress) and pick a cell (say A1) that will hold the
address of the target range - so in your Selection_Change procedu

Sheets("SaveAddress").Range("A1").Value = Target.Address

Hope this helps!

"Marie J-son" wrote:

Hi,

In the Worksheet_Change event, I evaluate with Intersect method where the
change take place. If not intersect is nothing, then I need to change format
in the cells BEFORE (the earlier selection). I guess I can do this if I can
"store" the Worksheet_SelectionChange Target.address and pick it up in the
Worksheet_Change event.

I don't want to store it as a temporary txt file, but solve the problem into
the VBA. How can this be done? If it can't with this approach, does anybody
know a better one?

/Kind Regards



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 22
Default Remember SelectionChange range in the Change sheet event?

Ohh...Right!

Thank you, you are right. There really are a lot of fields that can containt
variabels in Excel....IV x 65536 of them....
/Regards


"K Dales" skrev i meddelandet
...
Do you need to store it if the file is saved, or only while the file is
open?

If only while open, insert a module in VBA and use it to create a public
object variable of type Range:

Public StoreSelection as Range

Then, in your event procedu
Set StoreSelection = Target

If you need to store this range (by the address) between sessions (i.e.
even
when the book is closed) you can't do it simply in VBA since your VBA code
will necessarily be shut down when you leave Excel - but instead of a text
file, why not store it in the actual workbook? You could create a hidden
sheet (I'll call it SaveAddress) and pick a cell (say A1) that will hold
the
address of the target range - so in your Selection_Change procedu

Sheets("SaveAddress").Range("A1").Value = Target.Address

Hope this helps!

"Marie J-son" wrote:

Hi,

In the Worksheet_Change event, I evaluate with Intersect method where the
change take place. If not intersect is nothing, then I need to change
format
in the cells BEFORE (the earlier selection). I guess I can do this if I
can
"store" the Worksheet_SelectionChange Target.address and pick it up in
the
Worksheet_Change event.

I don't want to store it as a temporary txt file, but solve the problem
into
the VBA. How can this be done? If it can't with this approach, does
anybody
know a better one?

/Kind Regards





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
how to use selectionchange instead of doubleclick event? ghost Excel Discussion (Misc queries) 0 December 24th 08 05:00 AM
Worksheet SelectionChange Event mjack003 Excel Discussion (Misc queries) 2 May 8th 06 08:35 PM
SelectionChange event Stefi Excel Programming 2 October 28th 04 01:26 PM
How to preserve cut/copy range on SelectionChange event? pH7[_8_] Excel Programming 0 August 25th 04 01:39 PM
SelectionChange Event Squid[_3_] Excel Programming 5 February 11th 04 01:57 PM


All times are GMT +1. The time now is 06:08 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"