Loop until X or Y?

G

Guest

sub rotate()
dim i, x as integer

x = 1

do until sheets("Calc").cells(x,1) = ""

i = 1

do until sheets("Calc").cells(i,2) = sheets("Calc").cells(x,1)
i = i + 1
loop

x = x + 1
loop

end sub


Basically, I want to check one list with another, or similar, and I
generally want to look down a column of values until I get the specific line
that the value is copied.
Also, if I hit a blank cell I'll want to stop.

Imagine that column A is a collection of jobs, I want to put them in column
B, but want to remove the duplicates. So what i'm doing is going down A,
wanting to find where the duplicate in B is, and if its not there, to add it
to the bottom. So I really want to loop until the value matches, OR it hits a
blank cell...
 
G

Guest

maybe something like this:

Sub test()
Dim c As Range
Dim lRow As Long

lRow = Range("B65536").End(xlUp).Row + 1
For Each c In Range(Range("A1"), Range("A65536").End(xlUp))
On Error Resume Next
Application.WorksheetFunction.Match c.Value, Range("B:B"), False
If Err.Number > 0 Then
'value was not found in B, so add it
Range("B" & lRow).Value = c.Value
lRow = lRow + 1
End If
On Error GoTo 0
Next c

End Sub
 

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