An urgent modification

J

John21

Hi,

I’m trying to find a way to use this code:

Set RngColD = Range("D2", Range("D" & Rows.Count).End(xlUp))
Info = ""
For Each i In RngColD
If i.Value = Range("A493").Value Then
If Info = "" Then
Info = i.Offset(, 10).Value
Else
Info = Info & "," & i.Offset(, 10).Value
End If
End If
Next i
Range("I493") = Info
Info = ""


but is taking me too long because I have to apply it cell by cell, is
there any way to modified it to work in complete columns, something
like this>>>



Set RngColD = Range("D2", Range("D" & Rows.Count).End(xlUp))
Info = ""
For Each i In RngColD
If i.Value = Range("A493:A519").Value Then
If Info = "" Then
Info = i.Offset(, 10).Value
Else
Info = Info & "," & i.Offset(, 10).Value
End If
End If
Next i
Range("I493:A519") = Info
Info = ""
 
G

Guest

dim RngColD as Range, Info as Variant, Info1 as Variant
Dim s as String
s = ""
Set RngColD = Range("D2", Range("D" & Rows.Count).End(xlUp))
Info = RndColD.Value
Info1 = RndColD.Offset(0,10).Value
For i = 1 to Ubound(info,1)
If info(i,1) = Range("A493").Value Then
If s = "" Then
s = Info1(i)
Else
s = s & "," & Info1(i)
End If
End If
Next i
Range("I493").Value = s
s = ""
 
J

John21

dim RngColD as Range, Info as Variant, Info1 as Variant
Dim s as String
s = ""
Set RngColD = Range("D2", Range("D" & Rows.Count).End(xlUp))
Info = RndColD.Value
Info1 = RndColD.Offset(0,10).Value
For i = 1 to Ubound(info,1)
If info(i,1) = Range("A493").Value Then
If s = "" Then
s = Info1(i)
Else
s = s & "," & Info1(i)
End If
End If
Next i
Range("I493").Value = s
s = ""


in [Info = RndColD.Value] is giving and error something about "Objec
required
 
G

Guest

just a spelling error I would think RndColD should be RngColD

dim RngColD as Range, Info as Variant, Info1 as Variant
Dim s as String
s = ""
Set RngColD = Range("D2", Range("D" & Rows.Count).End(xlUp))
Info = RngColD.Value
Info1 = RngColD.Offset(0,10).Value
For i = 1 to Ubound(info,1)
If info(i,1) = Range("A493").Value Then
If s = "" Then
s = Info1(i)
Else
s = s & "," & Info1(i)
End If
End If
Next i
Range("I493").Value = s
s = ""
 
J

John21

John21 said:
dim RngColD as Range, Info as Variant, Info1 as Variant
Dim s as String
s = ""
Set RngColD = Range("D2", Range("D" & Rows.Count).End(xlUp))
Info = RndColD.Value
Info1 = RndColD.Offset(0,10).Value
For i = 1 to Ubound(info,1)
If info(i,1) = Range("A493").Value Then
If s = "" Then
s = Info1(i)
Else
s = s & "," & Info1(i)
End If
End If
Next i
Range("I493").Value = s
s = ""


in [s = Info1(i)] is giving and error something about "Subscript out o
range
 
G

Guest

Yep, here is the correction

dim RngColD as Range, Info as Variant, Info1 as Variant
Dim s as String
s = ""
Set RngColD = Range("D2", Range("D" & Rows.Count).End(xlUp))
Info = RngColD.Value
Info1 = RngColD.Offset(0,10).Value
For i = 1 to Ubound(info,1)
If info(i,1) = Range("A493").Value Then
If s = "" Then
s = Info1(i,1)
Else
s = s & "," & Info1(i,1)
End If
End If
Next i
Range("I493").Value = s
s = ""

--
Regards,
Tom Ogilvy


John21 said:
dim RngColD as Range, Info as Variant, Info1 as Variant
Dim s as String
s = ""
Set RngColD = Range("D2", Range("D" & Rows.Count).End(xlUp))
Info = RndColD.Value
Info1 = RndColD.Offset(0,10).Value
For i = 1 to Ubound(info,1)
If info(i,1) = Range("A493").Value Then
If s = "" Then
s = Info1(i)
Else
s = s & "," & Info1(i)
End If
End If
Next i
Range("I493").Value = s
s = ""


in [s = Info1(i)] is giving and error something about "Subscript out of
range"
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top