Do Until and For problem

AlexCS

Board Regular
Joined
Oct 31, 2011
Messages
78
Hi everyone,

The below code is designed to pick up variable levar from a list of values in the Masterlist tab and colour each row from the JDE Cardex tab in which levar appears. While it does this, the code would not stop searching for levar once the Do Until condition is fulfilled and thus searches for the first levar forever. Please help since I have been trying to fix this for one full day without success :(

Thanks a lot!

Alex

Sheets("Masterlist").Select
ActiveSheet.Cells(1, 1).CurrentRegion.Select
liniutze = Selection.Rows.Count

Dim levar As String
Dim numero As Integer
Dim rain As String

For g = 2 To liniutze
levar = Sheets("Masterlist").Cells(g, 1).Value
numero = 15
Do Until rain = "GRAND TOTAL"
For t = 2 To 600
Sheets("JDE Cardex").Select
On Error Resume Next
Worksheets("JDE Cardex").Columns("A").Find(What:=levar, After:=Cells(numero + 1, 1), LookIn:=xlValues, LookAt:= _
xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:=False, SearchFormat:=False).EntireRow.Select
numero = ActiveCell.Row
Sheets("JDE Cardex").Rows(numero).EntireRow.Interior.ColorIndex = 27
ActiveSheet.Cells(numero + 1, 1).Activate
Cells.FindNext(After:=ActiveCell).Activate
rain = Sheets("JDE Cardex").Cells(numero + 4, 4).Value
Next t
Loop
Next g
 

Excel Facts

Excel motto
Not everything I do at work revolves around Excel. Only the fun parts.
Hi,
try using .select instead of .activate

and does this value ever = GRAND TOTAL <written exactly like that as well?
 
Upvote 0
Thanks a lot..I just reverted to a filter instead of the find and I got it to work eventually.

Regards,

Alex
 
Upvote 0

Forum statistics

Threads
1,216,765
Messages
6,132,594
Members
449,737
Latest member
naes

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top