LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,069
Default Find and loop

I have a fairly simple find and loop set up to find and color certian rows.
Currently I see two problems: First, my code finds my find value, but does
not appear to meet my IF THEN criteria. Meaning it has added color to a
row that does not meet this criteria in my code... If rngFound.Offset(0,
-11).Value Sheets("data").Range("z4").Value Then "Color the row"... Is my
offset the wrong number? I have my find column in column U and the value I
am picking in the offset is in column J... isn't that offset(0,-11)?

The other thing is that when it finds and colors the first row in the loop,
it then ends the code, instead of continuing to find the rest of the rows
that meet the criteria.

Here is the code Thanks for the help!



Dim rngToSearch As Range
Dim wks As Worksheet
Dim rngFound As Range
Sheets("corps").Select
Call FindErrors
Range("u10").Select
Selection.EntireColumn.Hidden = False
Set wks = Sheets("corps")
Set rngToSearch = wks.Range("u11:u712")
Set rngFound = rngToSearch.find(what:="1", LookIn:=xlValues,
lookat:=xlWhole)

If rngFound.Offset(0, -11).Value Sheets("data").Range("z4").Value Then
saddr = rngFound.Address
r = rngFound.Row
Do
Range("a" & r, "s" & r).Select
With Selection.Interior
.ColorIndex = 36
.Pattern = xlSolid
End With

Set rngFound = rngToSearch.FindNext(rngFound)
Loop Until rngFound Is Nothing Or rngFound.Address = saddr
Range("u10").Select
Selection.EntireColumn.Hidden = True
end if
end sub
 
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
Find loop doesn't loop JSnow Excel Discussion (Misc queries) 2 June 24th 09 08:28 PM
Find & loop in VBA Noemi Excel Discussion (Misc queries) 3 January 25th 06 03:39 AM
Loop and find less than... John Excel Programming 2 August 30th 05 03:34 PM
Find in a loop John Excel Programming 2 August 2nd 05 06:10 PM
Find loop Jamie[_8_] Excel Programming 2 April 22nd 04 10:00 PM


All times are GMT +1. The time now is 11:31 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"