LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
EWR EWR is offline
external usenet poster
 
Posts: 8
Default loop non adjacent cells

I am trying to execute a macro for all the rows which a user pastes a value
into. For example, the user selects cells AJ94, AJ108, AJ120 and pastes a
copied value.
The problem is that the msgbox returns $AJ$94 3 times.
I have (excuse any mistakes I have...I cut a whole bunch of junk)
Any thoughts?

Private Sub Worksheet_Change(ByVal Target As Range)
Application.EnableEvents = True
Dim DataRng, TrgtRng As String
Dim rng, c As Range
DataRng = ActiveWorkbook.Names("trgtrng").RefersToRange.Addr ess
€˜trgtrng refers to column AJ in the example
If Not Application.Intersect(Target, Range(DataRng)) Is Nothing Then
TrgtRng = Target.AddressLocal()
Set rng = Range(TrgtRng)
For Each c In trng
MsgBox ActiveCell.AddressLocal()
Next c
Endif
End Sub

 
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
compare 2 column cells and return the adjacent columns cells data of the cell trebor57 Excel Worksheet Functions 1 February 1st 11 02:54 PM
Compare 1 cell to column of cells returning adjacent cells info? Mr. Fine Excel Worksheet Functions 1 April 15th 10 07:36 PM
Add cells on two adjacent rows but non-adjacent columns Eve Excel Worksheet Functions 14 October 20th 09 02:32 AM
By selecting cells adjacent to cells tally sheet tom Excel Worksheet Functions 2 September 20th 06 07:09 PM
How do I fill (copy) nonadjacent cells to adjacent cells? BuckyGeorge Excel Discussion (Misc queries) 2 December 22nd 05 04:18 AM


All times are GMT +1. The time now is 07:01 AM.

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

About Us

"It's about Microsoft Excel"