Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 309
Default Worksheet_Change() and Range question

If someone highlights a block of cells and presses "delete"
to delete all the data in those cells, Excel will pass all
those changed cell addresses to "Worksheet_Change()" into
the "Target" variable.

My question is, how do I enumerate through all the cells
contained in the "Target" range variable?? The "Target"
variable seems to contain a single string of all the cell
addresses that were changed, and I'm looking for an easy
way to extract each cell address from the "Target" variable.

I initially thought I could use the following code, but I was
wrong:

Public Sub Worksheet_Change (ByVal Target as Range)

for i = 1 to Target.Count
nextAddress = Target(i).Address(0,0) ' Get next changed address??
Next i

End Sub

Thank you!
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 913
Default Worksheet_Change() and Range question

On Sat, 12 Dec 2009 15:32:19 -0700, "Robert Crandal"
wrote:

If someone highlights a block of cells and presses "delete"
to delete all the data in those cells, Excel will pass all
those changed cell addresses to "Worksheet_Change()" into
the "Target" variable.

My question is, how do I enumerate through all the cells
contained in the "Target" range variable?? The "Target"
variable seems to contain a single string of all the cell
addresses that were changed, and I'm looking for an easy
way to extract each cell address from the "Target" variable.

I initially thought I could use the following code, but I was
wrong:

Public Sub Worksheet_Change (ByVal Target as Range)

for i = 1 to Target.Count
nextAddress = Target(i).Address(0,0) ' Get next changed address??
Next i

End Sub

Thank you!


Try this:

Private Sub Worksheet_Change(ByVal Target As Range)
For Each c In Target
nextaddress = c.Address
Next c
End Sub

Hope this helps / Lars-Åke
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 309
Default Worksheet_Change() and Range question

Yes, that works excellent. Just what I was looking for.

BTW, what would be the correct notation to just extract a SINGLE
address? For example, what if I am only interested in the second
cell address in the list??

thankx again


"Lars-Åke Aspelin" wrote in message
...

Try this:

Private Sub Worksheet_Change(ByVal Target As Range)
For Each c In Target
nextaddress = c.Address
Next c
End Sub


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 913
Default Worksheet_Change() and Range question

Try this

Target(2).Address

Hope this helps / Lars-Åke


On Sat, 12 Dec 2009 16:11:15 -0700, "Robert Crandal"
wrote:

Yes, that works excellent. Just what I was looking for.

BTW, what would be the correct notation to just extract a SINGLE
address? For example, what if I am only interested in the second
cell address in the list??

thankx again


"Lars-Åke Aspelin" wrote in message
.. .

Try this:

Private Sub Worksheet_Change(ByVal Target As Range)
For Each c In Target
nextaddress = c.Address
Next c
End Sub


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
Worksheet_Change() and range question Robert Crandal Excel Programming 8 December 3rd 09 09:14 AM
Worksheet_change question אלי Excel Programming 1 April 27th 09 07:35 AM
worksheet_change question HRman Excel Programming 2 March 30th 06 05:35 PM
Excel VBA .... Worksheet_Change(ByVal Target As Range) question Joseph Donnelly Excel Programming 2 May 17th 04 08:35 PM
Worksheet_Change event question marwan hefnawy Excel Programming 1 September 10th 03 08:53 PM


All times are GMT +1. The time now is 08:19 AM.

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"