#1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Loop

How do I stop this after the last life o I am new and not very good at thi

Sub life_o(
Range("A1:A8000").Selec
D

Set FoundCell = Cells.Find(What:="life o", After:=ActiveCell,
LookIn:=xlValues, LookAt:=xlPart, SearchOrder:=xlByColumns,
SearchDirection:=xlNext, MatchCase:=False
If FoundCell Is Nothing The
Els
FoundCell.Offset(0, 1).Selec
End I
FoundCell.Offset(0, 1).Selec
ActiveCell.Value = "1
ActiveCell.Offset(0, -1).Selec
Loop Until FoundCell Is Nothin
End Sub
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 201
Default Loop

Esau
As written, your macro is illogical and will produce an error if
FoundCell is nothing. Post back and detail exactly what you want this macro
to do. HTH Otto
"Esau" wrote in message
...
How do I stop this after the last life o I am new and not very good at

this

Sub life_o()
Range("A1:A8000").Select
Do

Set FoundCell = Cells.Find(What:="life o", After:=ActiveCell, _
LookIn:=xlValues, LookAt:=xlPart, SearchOrder:=xlByColumns, _
SearchDirection:=xlNext, MatchCase:=False)
If FoundCell Is Nothing Then
Else
FoundCell.Offset(0, 1).Select
End If
FoundCell.Offset(0, 1).Select
ActiveCell.Value = "1"
ActiveCell.Offset(0, -1).Select
Loop Until FoundCell Is Nothing
End Sub



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default Loop

In Column A from A1:A8000 Life o appears about 140 times I need the value 1 in column B next to life o.
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,337
Default Loop

you could do a for/each
for each c in a1:a8000
if c="whatever"then c.offset(,1)=1
next
OR it would probably be quicker to
use datafilterautofilterfilter on your whateverthen use
specialcells(xlvisible), etc

--
Don Guillett
SalesAid Software

"Esau" wrote in message
...
In Column A from A1:A8000 Life o appears about 140 times I need the value

1 in column B next to life o.


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Loop

Sub life_o()
Dim FoundCell As Range
Dim FirstAddress As String
With Range("A1:A8000")
Set FoundCell = .Find(What:="life o", _
After:=ActiveCell, _
LookIn:=xlValues, _
LookAt:=xlPart, _
SearchOrder:=xlByColumns, _
SearchDirection:=xlNext, _
MatchCase:=False)
FirstAddress = FoundCell.Address
Do
If Not FoundCell Is Nothing Then
FoundCell.Offset(0, 2).Value = "1"
End If
Set FoundCell = .FindNext(FoundCell)
Loop While Not FoundCell Is Nothing And FoundCell.Address <
FirstAddress
End With
End Sub

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"Esau" wrote in message
...
How do I stop this after the last life o I am new and not very good at

this

Sub life_o()
Range("A1:A8000").Select
Do

Set FoundCell = Cells.Find(What:="life o", After:=ActiveCell, _
LookIn:=xlValues, LookAt:=xlPart, SearchOrder:=xlByColumns, _
SearchDirection:=xlNext, MatchCase:=False)
If FoundCell Is Nothing Then
Else
FoundCell.Offset(0, 1).Select
End If
FoundCell.Offset(0, 1).Select
ActiveCell.Value = "1"
ActiveCell.Offset(0, -1).Select
Loop Until FoundCell Is Nothing
End Sub





  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Loop

Works great Bob I wish I could write that good maybe someda

Thanks Alo
Esau
  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Loop

Got most of it from Help<vbg

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"Esau" wrote in message
...
Works great Bob I wish I could write that good maybe someday

Thanks Alot
Esau



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
Find loop doesn't loop JSnow Excel Discussion (Misc queries) 2 June 24th 09 08:28 PM
Loop ? chrisnsmith Excel Discussion (Misc queries) 6 February 21st 09 03:54 PM
Worksheet_Change - loop within a loop bgm Excel Programming 1 January 19th 04 01:27 PM
HELP!!!! Can't stop a loop (NOT an infinite loop) TBA[_2_] Excel Programming 3 December 14th 03 03:33 PM
for-each-next loop Valeria[_2_] Excel Programming 2 December 2nd 03 02:58 PM


All times are GMT +1. The time now is 10:29 AM.

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"