ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   FindFirst (https://www.excelbanter.com/excel-programming/372686-findfirst.html)

kirkm[_6_]

FindFirst
 

Is there a quick way to find the first instance of something in a cell
- rather than move through line by line?

Thanks - Kirk

NickHK

FindFirst
 
Kirk,
Check out the Find method in the Help.

NickHK

"kirkm" wrote in message
...

Is there a quick way to find the first instance of something in a cell
- rather than move through line by line?

Thanks - Kirk




Bob Phillips

FindFirst
 
Straight from help

With Worksheets(1).Range("a1:a500")
Set c = .Find(2, lookin:=xlValues)
If Not c Is Nothing Then
firstAddress = c.Address
Do
c.Value = 5
Set c = .FindNext(c)
Loop While Not c Is Nothing And c.Address < firstAddress
End If
End With

--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)

"kirkm" wrote in message
...

Is there a quick way to find the first instance of something in a cell
- rather than move through line by line?

Thanks - Kirk




kirkm[_6_]

FindFirst
 
On Tue, 12 Sep 2006 14:43:36 +0800, "NickHK"
wrote:

Kirk,
Check out the Find method in the Help.

NickHK


Yeah.... I tried that. I seem to have just the Office Assistant which
told me to click on Find.... not much use as I want to use VB.

kirkm[_6_]

FindFirst
 
On Tue, 12 Sep 2006 08:54:51 +0100, "Bob Phillips"
wrote:

Straight from help

With Worksheets(1).Range("a1:a500")
Set c = .Find(2, lookin:=xlValues)
If Not c Is Nothing Then
firstAddress = c.Address
Do
c.Value = 5
Set c = .FindNext(c)
Loop While Not c Is Nothing And c.Address < firstAddress
End If
End With


Thanks Bob... amazing stuff! Means absolutely nothing to me!
My 'Help' seems to be missing..... I'll keep Googling :)

Cheers - Kirk

NickHK

FindFirst
 
You need the help in the VBA IDE, not Excel help.

Press Alt+F11, then F1.
VBA Help is an option during Office installation, so if it is not available
you will need add it.

NickHK

"kirkm" wrote in message
...
On Tue, 12 Sep 2006 14:43:36 +0800, "NickHK"
wrote:

Kirk,
Check out the Find method in the Help.

NickHK


Yeah.... I tried that. I seem to have just the Office Assistant which
told me to click on Find.... not much use as I want to use VB.




Bob Phillips

FindFirst
 
It is quite straightforward

A1:A500 is the range being looked at

2 is the value being looked for

If Not c Is Nothing means that something was found.

--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)

"kirkm" wrote in message
...
On Tue, 12 Sep 2006 08:54:51 +0100, "Bob Phillips"
wrote:

Straight from help

With Worksheets(1).Range("a1:a500")
Set c = .Find(2, lookin:=xlValues)
If Not c Is Nothing Then
firstAddress = c.Address
Do
c.Value = 5
Set c = .FindNext(c)
Loop While Not c Is Nothing And c.Address < firstAddress
End If
End With


Thanks Bob... amazing stuff! Means absolutely nothing to me!
My 'Help' seems to be missing..... I'll keep Googling :)

Cheers - Kirk





All times are GMT +1. The time now is 09:05 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com