vzachin
03-25-2010, 11:40 AM
hi,
i need help with a Find String. In column H, i have an Order number. I need to check the first 7 characters of the order number and see if that is in column B. In column B, the order number can be anywhere in the string. If the order number from H is found in column B, then i want to place that order number from column B into Column K and also the Status from Column D. If others are found, then continue to the next column + 1.
There will be no more than 20 orders that can be found so i'm not worried about the column contraint.
the columns of data can up to 1000
Sub comparedat()
col = 7
neorw = Cells(Rows.Count, "f").End(xlUp).Row
olerw = Cells(Rows.Count, "b").End(xlUp).Row
For i = 2 To neorw
neoord = Left(Range("f" & i), 7)
For j = 2 To olerw
Set oleord = Range("b" & j)
If Range("f" & i).Value Like Range("b" & j).Value Then
col = col + 1
Cells(i, col) = oleord
Cells(i, col + 1) = Range("d" & j)
col = col + 1
End If
Next j
Next i
End Sub
this is not the most effiecient code but i'm confortable with it. i'm having trouble with the LIKE statement. it doesn't find any data at all.
thanks
zach
i need help with a Find String. In column H, i have an Order number. I need to check the first 7 characters of the order number and see if that is in column B. In column B, the order number can be anywhere in the string. If the order number from H is found in column B, then i want to place that order number from column B into Column K and also the Status from Column D. If others are found, then continue to the next column + 1.
There will be no more than 20 orders that can be found so i'm not worried about the column contraint.
the columns of data can up to 1000
Sub comparedat()
col = 7
neorw = Cells(Rows.Count, "f").End(xlUp).Row
olerw = Cells(Rows.Count, "b").End(xlUp).Row
For i = 2 To neorw
neoord = Left(Range("f" & i), 7)
For j = 2 To olerw
Set oleord = Range("b" & j)
If Range("f" & i).Value Like Range("b" & j).Value Then
col = col + 1
Cells(i, col) = oleord
Cells(i, col + 1) = Range("d" & j)
col = col + 1
End If
Next j
Next i
End Sub
this is not the most effiecient code but i'm confortable with it. i'm having trouble with the LIKE statement. it doesn't find any data at all.
thanks
zach