View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
joel[_912_] joel[_912_] is offline
external usenet poster
 
Posts: 1
Default Find and loop help-multiple columns


I added a couple of For loops to your code to solve the problem. I did
not test the code but you should be able to figure it out yourself


With lastperiod

'Find the last used column
LastCol = .UsedRange.Columns.Count

'find the last row
LastRow = .Cells.Find(What:="*", _
lookin:=xlvalues, _
lookat:=xlpart, _
SearchDirection:=xlPrevious, _
SearchOrder:=xlRows).Row

'paste the info
Paste

for ColCount = 1 to Lastcol
if .cells(2,Colcount) = "Route Number(s)" then
for Rowcount = Lastrow to 4 step -1
Set rngToFind =
range(.cells(4,ColCount),.cells(RowCount,colcount) )
Route = .cells(RowCount,ColCount)
Set rngFound = rngToFind.Find(What:=Route,
MatchCase:=False)
If rngFound Is Nothing Then
rng.Offset(0, 10).Value = "First Time"
Else
rng.Offset(0, 10).Value = "Repeat"
end if
next RowCount
end if
next Colcount
End With


--
joel
------------------------------------------------------------------------
joel's Profile: http://www.thecodecage.com/forumz/member.php?u=229
View this thread: http://www.thecodecage.com/forumz/sh...d.php?t=197104

http://www.thecodecage.com/forumz