I have a list of values in the range H:H, J:J, L:L and from these values
I want to create a list in column A (A:A) of only the unique values found in the other three columns. For example:
H J L
__________________________
Apple Orange Grape
Pear Lemon Apple
Grape Orange Lime
so column A should contain:
A
_______________
Apple
Pear
Grape
Orange
Lemon
Lime
What I have tried so far is:
To take each individual cell (through 2500 rows, since I don't know how to loop until it picks up every value - I just picked a very large number of rows) in columns H, J, and L and compare it to each cell in A (using another loop through A1:A2500), but this takes entirely too long (see code below).
For rwIndex = 4 To 2500
For rwIndex1 = 4 To 2500
If Worksheets("Sheet1".Cells(rwIndex, 8).Value = Worksheets("Sheet1".Cells(rwIndex1, 1).Value Then
Worksheets("Sheet1".Cells(rwIndex, 1).Value = Worksheets("Sheet1".Cells(rwIndex, 8).Value
End If
Next rwIndex1
Next rwIndex
I've also tried using the "instr" function with String1 = Range("A1:A2500".Select (although I thought I wanted to use .Value here, but it tells me there's a "Type Mismatch" and String2 = (rwIndex, 8).Value and if the Instr result = 0 then copy the value in column H to column A (see code below). The problem with this code, though, is that the Instr statement ALWAYS equals 0; even when I intend for it not too.
For rwIndex = 4 To 2500
If InStr(Worksheets("Sheet1".Range
("A1:A2500".Select, Worksheets("Sheet1".Cells (rwIndex, 8).Value) = 0 Then
Worksheets("Sheet1".Cells(rwIndex, 1).Value = Worksheets("Sheet1".Cells(rwIndex, 8).Value
End If
Next rwIndex
So, it seems my task was fairly simple when I started the whole project, but I feel I may be making the code much for complex than need be. Am I missing the boat here?
Please help!!
Thanks!
Kelly
I want to create a list in column A (A:A) of only the unique values found in the other three columns. For example:
H J L
__________________________
Apple Orange Grape
Pear Lemon Apple
Grape Orange Lime
so column A should contain:
A
_______________
Apple
Pear
Grape
Orange
Lemon
Lime
What I have tried so far is:
To take each individual cell (through 2500 rows, since I don't know how to loop until it picks up every value - I just picked a very large number of rows) in columns H, J, and L and compare it to each cell in A (using another loop through A1:A2500), but this takes entirely too long (see code below).
For rwIndex = 4 To 2500
For rwIndex1 = 4 To 2500
If Worksheets("Sheet1".Cells(rwIndex, 8).Value = Worksheets("Sheet1".Cells(rwIndex1, 1).Value Then
Worksheets("Sheet1".Cells(rwIndex, 1).Value = Worksheets("Sheet1".Cells(rwIndex, 8).Value
End If
Next rwIndex1
Next rwIndex
I've also tried using the "instr" function with String1 = Range("A1:A2500".Select (although I thought I wanted to use .Value here, but it tells me there's a "Type Mismatch" and String2 = (rwIndex, 8).Value and if the Instr result = 0 then copy the value in column H to column A (see code below). The problem with this code, though, is that the Instr statement ALWAYS equals 0; even when I intend for it not too.
For rwIndex = 4 To 2500
If InStr(Worksheets("Sheet1".Range
("A1:A2500".Select, Worksheets("Sheet1".Cells (rwIndex, 8).Value) = 0 Then
Worksheets("Sheet1".Cells(rwIndex, 1).Value = Worksheets("Sheet1".Cells(rwIndex, 8).Value
End If
Next rwIndex
So, it seems my task was fairly simple when I started the whole project, but I feel I may be making the code much for complex than need be. Am I missing the boat here?
Please help!!
Thanks!
Kelly