LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Troublesome Code

First,

Range("b1:b150", "d1:D150")
is the same as:
range("B1:D150")

If you really wanted just rows 1:150 in column B or D, then use:
range("b1:b150,d1:d150")



Private Sub Worksheet_Change(ByVal Target As Range)
dim myRow as long
dim myRng as range

If Target.Cells.Count 1 Then Exit Sub
myrow = target.row -1

If Application.Intersect(Range("b1:d150"), Target) Is Nothing Then
exit sub
end if

set myrng = me.range(.cells(myrow,"D"),.cells(myrow,"X"))

'stop the change from firing this event
application.enableevents = false
myrng.Replace what:="L??O???", _
Replacement:=me.Cells(target.row, "a").Value, _
LookAt:=xlPart, _
SearchOrder:=xlByRows, _
MatchCase:=False

Target.Offset(1, 0).Select
application.enableevents =true

End Sub

(Untested, uncompiled.)

Mark Dullingham wrote:

I have the following code in my work book. It does exactly what I want it to
apart from each time a value is changed and the code runs the code scrolls
back through the entire sheet and as the number of rows is getting quite
extensive now this can take some time.
Does anyone have any idea how to stop this from happening.

Many thanks in advance

Mark Dullingham

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Cells.Count 1 Then Exit Sub
If Not Application.Intersect(Range("b1:b150", "d1:d150"), Target) Is
Nothing Then
Range("D" & ActiveCell.Offset(-1, 0).Row & ":X" & ActiveCell.Offset(-1,
0).Row).Select
Selection.Replace what:="L??O???", _
Replacement:=Cells(ActiveCell.Row, "a").Value, _
LookAt:=xlPart, _
SearchOrder:=xlByRows, _
MatchCase:=False
Target.Offset(1, 0).Select
End If


End Sub


--

Dave Peterson
 
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
split post code (zip code) out of cell that includes full address Concord Excel Discussion (Misc queries) 4 October 15th 09 06:59 PM
Help with troublesome .CSV fields! markpruett Excel Discussion (Misc queries) 3 March 4th 09 09:37 AM
Excel code convert to Access code - Concat & eliminate duplicates italia Excel Programming 1 September 12th 06 12:14 AM
aNOTHer troublesome equation Micayla Bergen Excel Discussion (Misc queries) 7 August 15th 05 03:28 AM
stubborn Excel crash when editing code with code, one solution Brian Murphy Excel Programming 0 February 20th 05 05:56 AM


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