Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 130
Default 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...

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 857
Default 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...

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Naming Worksheets - Loop within a loop issue klysell Excel Programming 5 March 29th 07 05:48 AM
Naming Worksheets - Loop within a loop issue klysell Excel Programming 0 March 27th 07 11:17 PM
(Complex) Loop within loop to create worksheets klysell Excel Programming 1 March 20th 07 12:03 AM
Advancing outer Loop Based on criteria of inner loop ExcelMonkey Excel Programming 1 August 15th 05 05:23 PM
Problem adding charts using Do-Loop Until loop Chris Bromley[_2_] Excel Programming 2 May 23rd 05 01:31 PM


All times are GMT +1. The time now is 12:41 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"