Loop

G

Guest

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
 
O

Otto Moehrbach

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
 
G

Guest

In Column A from A1:A8000 Life o appears about 140 times I need the value 1 in column B next to life o.
 
D

Don Guillett

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 data>filter>autofilter>filter on your whatever>then use
specialcells(xlvisible), etc

--
Don Guillett
SalesAid Software
(e-mail address removed)
Esau said:
In Column A from A1:A8000 Life o appears about 140 times I need the value
1 in column B next to life o.
 
B

Bob Phillips

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)
 
B

Bob Phillips

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)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top