![]() |
Loop until X or Y?
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... |
Loop until X or Y?
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 -- Hope that helps. Vergel Adriano "PaulW" wrote: 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... |
All times are GMT +1. The time now is 02:50 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com