charleymax
New Member
- Joined
- Sep 10, 2010
- Messages
- 39
Hi all,
I have the below that was modified from code kindly created by MikeG...
I'm having trouble though as I'm trying to run in in a worksheet with 1500 rows and I end up with the following error message:
Run time error 1004
out of stack space
Anyone know what I'm doing wrong.. Perhaps I just need ot to update for any rows with the same Doc # as the one I just updated... But I think every time I change 1 cell it re checks the entire sheet...
Just to clarify this is designed to update the above sheet so that anytime I update a Doc # in col J Col B (Crossover) is updated with any project names from Col E that contain that Doc number... As I stated my code running on worksheet_change is I think rechecking & updating everything everytime I update... I might want to simplify and only update rows where Doc # matches the cells I updated any maybe only do the update on save or on close.... Can anyone advise... (reason for edit to add this paragraph to clarify)
I have the below that was modified from code kindly created by MikeG...
I'm having trouble though as I'm trying to run in in a worksheet with 1500 rows and I end up with the following error message:
Run time error 1004
out of stack space
Anyone know what I'm doing wrong.. Perhaps I just need ot to update for any rows with the same Doc # as the one I just updated... But I think every time I change 1 cell it re checks the entire sheet...
Code:
Private Sub Worksheet_Change(ByVal Target As Range)
Dim Rng As Range, Dn As Range
Dim n As Long
Dim Q, K
Dim R As Range
Set Rng = Range(Range("J2"), Range("j" & Rows.Count).End(xlUp))
ReDim ray(1 To Rng.Count, 1 To 2)
With CreateObject("scripting.dictionary")
.CompareMode = vbTextCompare
For Each Dn In Rng
If Not .Exists(Dn.Value) Then
n = n + 1
.Add Dn.Value, Array(n, Dn.Offset(, -5), Dn.Offset(, -8).Address)
Else
Q = .Item(Dn.Value)
Q(1) = Q(1) & ", " & Dn.Offset(, -5)
Q(2) = Q(2) & ", " & Dn.Offset(, -8).Address
.Item(Dn.Value) = Q
End If
Next
For Each K In .keys
Set Rng = Range(.Item(K)(2))
For Each R In Rng
R = IIf(InStr(.Item(K)(1), ",") > 1, .Item(K)(1), "None")
Next R
Next K
End With
End Sub
Just to clarify this is designed to update the above sheet so that anytime I update a Doc # in col J Col B (Crossover) is updated with any project names from Col E that contain that Doc number... As I stated my code running on worksheet_change is I think rechecking & updating everything everytime I update... I might want to simplify and only update rows where Doc # matches the cells I updated any maybe only do the update on save or on close.... Can anyone advise... (reason for edit to add this paragraph to clarify)
Last edited: