Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 125
Default Find a string

I am trying to find the row in which a string occurs but I just do not
understand how.
Can you complete this for me?

Sub zTest()

sDName = "D01-007"

iDRow = .Find(sDName, LookIn:=Range(Cells(6, 2), Cells(30, 2)))

End Sub

Francis Hookham


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,124
Default Find a string

Perhaps a look in the vba help index for FIND would have been of assistance.
This finds if that is the only thing in the cell ( you did not specify)
Sub zTest()

sdname = "D01-007"

'iDRow = .Find(sDName, LookIn:=Range(Cells(6, 2), Cells(30, 2))).Row

x = Range(Cells(6, 2), Cells(30, 2)).Find(sdname).Row
MsgBox x
End Sub

--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"Francis Hookham" wrote in message
...
I am trying to find the row in which a string occurs but I just do not
understand how.
Can you complete this for me?

Sub zTest()

sDName = "D01-007"

iDRow = .Find(sDName, LookIn:=Range(Cells(6, 2), Cells(30, 2)))

End Sub

Francis Hookham



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default Find a string

Sub zTest()
Dim sDname as String, r as Range, r1 as Range
sDName = "D01-007"
set r = Range(Cells(6, 2), Cells(30, 2))
set r1 =r.Find(sDName)
if not r1 is nothing then
msgbox r1.address
else
msgbox "Not found"
End if




End Sub


Regards,
Tom Ogilvy


"Francis Hookham" wrote:

I am trying to find the row in which a string occurs but I just do not
understand how.
Can you complete this for me?

Sub zTest()

sDName = "D01-007"

iDRow = .Find(sDName, LookIn:=Range(Cells(6, 2), Cells(30, 2)))

End Sub

Francis Hookham



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 125
Default Find a string

Many thanks Tom - I am most grateful.

I'll try both your and Don's answer - yours prompts me to error check which
I shall do.

Francis


"Tom Ogilvy" wrote in message
...
Sub zTest()
Dim sDname as String, r as Range, r1 as Range
sDName = "D01-007"
set r = Range(Cells(6, 2), Cells(30, 2))
set r1 =r.Find(sDName)
if not r1 is nothing then
msgbox r1.address
else
msgbox "Not found"
End if




End Sub


Regards,
Tom Ogilvy


"Francis Hookham" wrote:

I am trying to find the row in which a string occurs but I just do not
understand how.
Can you complete this for me?

Sub zTest()

sDName = "D01-007"

iDRow = .Find(sDName, LookIn:=Range(Cells(6, 2), Cells(30, 2)))

End Sub

Francis Hookham





  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 125
Default Find a string

Many thanks Don - I did look in Find but wasn't bright enough to realise I
should put .Row at the end.

How you MVPs put up with people like me I do not know - it is a fantastic
service - perhaps in my small way I do the same thing at a much lower level
when my club members ask me such things as why do they keep loosing
everything when, in Word, they type a uppercase A (they press CTRL instead
of shift and then over type everything!

Thanks

Francis

"Don Guillett" wrote in message
...
Perhaps a look in the vba help index for FIND would have been of
assistance.
This finds if that is the only thing in the cell ( you did not specify)
Sub zTest()

sdname = "D01-007"

'iDRow = .Find(sDName, LookIn:=Range(Cells(6, 2), Cells(30, 2))).Row

x = Range(Cells(6, 2), Cells(30, 2)).Find(sdname).Row
MsgBox x
End Sub

--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"Francis Hookham" wrote in message
...
I am trying to find the row in which a string occurs but I just do not
understand how.
Can you complete this for me?

Sub zTest()

sDName = "D01-007"

iDRow = .Find(sDName, LookIn:=Range(Cells(6, 2), Cells(30, 2)))

End Sub

Francis Hookham





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 String in another string - only between spaces Nir Excel Worksheet Functions 9 November 2nd 06 11:31 AM
Find Many String options in ONE String Nir Excel Worksheet Functions 6 October 26th 06 07:13 AM
search a string withing a string : find / search hangs itarnak[_9_] Excel Programming 4 October 24th 05 03:19 PM
backwards find function to find character in a string of text Ashleigh K. Excel Programming 1 January 14th 04 04:36 PM
find a string inside another string MarkS Excel Programming 1 January 13th 04 02:55 AM


All times are GMT +1. The time now is 04:15 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"