Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Excel / New Users / January 2007

Tip: Looking for answers? Try searching our database.

Make code Intersect applicable for all rows.

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
AA Arens - 02 Jan 2007 02:24 GMT
I have undermentioned code in the Private Sub Worksheet_Change(ByVal
Target As Range)

If Not Intersect(Target, Me.Range("C07")) Is Nothing Then
 If Target.Count > 1 Then Exit Sub
 Application.EnableEvents = False
 Set rng = ActiveWorkbook.Names(Target.Value).RefersToRange
 Me.Range("D07").Value = rng.Offset(0, 0).Value
End If

I do have the first two columns with combo's.

The code is repreated 50 times, as I have 50 rows.

How to make it applicable for all rows, so I mentioned the code only
one time?

Bart
Ex 2003
Jim Cone - 02 Jan 2007 03:56 GMT
Untested...

Private Sub Worksheet_Change(ByVal Target As Range)
On Error GoTo BadCodeExists

If Not Intersect(Target, Me.Range("C07:CO56")) Is Nothing Then
 If Target.Count > 1 Then Exit Sub
 Dim rng As Excel.Range
 Application.EnableEvents = False
 Set rng = ActiveWorkbook.Names(Target.Value).RefersToRange
 Target.Offset(0, 26).Value = rng.Value
End If

BadCodeExists:
Application.EnableEvents = True
End Sub
----------
Jim Cone
San Francisco, USA
http://www.realezsites.com/bus/primitivesoftware

"AA Arens"
<bartvandongen@gmail.com>
wrote in message
I have undermentioned code in the Private Sub Worksheet_Change(ByVal
Target As Range)

If Not Intersect(Target, Me.Range("C07")) Is Nothing Then
 If Target.Count > 1 Then Exit Sub
 Application.EnableEvents = False
 Set rng = ActiveWorkbook.Names(Target.Value).RefersToRange
 Me.Range("D07").Value = rng.Offset(0, 0).Value
End If

I do have the first two columns with combo's.
The code is repreated 50 times, as I have 50 rows.
How to make it applicable for all rows, so I mentioned the code only
one time?
Bart
Ex 2003

Rate this thread:






 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.