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

Hello,
I can not seem to figure out the FIND command in VB code. It works great
in the worksheet. What I have is several hundred cells that start off with 2
to 5 characters then a "." then 8 numbers followed by another "." 3 numbers
then 2 letters (ie.. ABCD.12345678.012AB). I need the information in the
middle, the 12345678 by it's self. I try to use the following code, but it
does not like the FIND portion (Sub or Function not defined error)

If MID(Cells(irow, 3), FIND(".", Cells(irow, 3)) + 1, 8) = "12345678" then
..... do this code ....
End If

The only way I have been able to get the results I need is with the
following:

For i = 2 to 6
x = MID(Cells(irow, 3), i, 1)
If x = Chr(46) then ' the "."
s = i
Exit For
End If
Next
If MID(Cells(irow, 3), s + 1, 8) = "12345678" then
..... do this code ....
End If

This works but I really did not want to search several times on each and
every cell on hundreds of lines.

Any help would be greatly appreicated.

James K.


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 14
Default Help with vb Find

Hi James

To use a worksheet function in VBA it should be preceded by
"Application.WorksheetFunction"
i.e.

If MID(Cells(irow, 3), Application.WorksheetFunction.Find(".", Cells(irow,
3)) + 1, 8) = "12345678" then
..... do this code ....
End If



"james" wrote in message
...
Hello,
I can not seem to figure out the FIND command in VB code. It works

great
in the worksheet. What I have is several hundred cells that start off with

2
to 5 characters then a "." then 8 numbers followed by another "." 3

numbers
then 2 letters (ie.. ABCD.12345678.012AB). I need the information in the
middle, the 12345678 by it's self. I try to use the following code, but it
does not like the FIND portion (Sub or Function not defined error)

If MID(Cells(irow, 3), FIND(".", Cells(irow, 3)) + 1, 8) = "12345678" then
.... do this code ....
End If

The only way I have been able to get the results I need is with the
following:

For i = 2 to 6
x = MID(Cells(irow, 3), i, 1)
If x = Chr(46) then ' the "."
s = i
Exit For
End If
Next
If MID(Cells(irow, 3), s + 1, 8) = "12345678" then
.... do this code ....
End If

This works but I really did not want to search several times on each and
every cell on hundreds of lines.

Any help would be greatly appreicated.

James K.




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Help with vb Find

If MID(Cells(irow, 3), Instr(Cells(irow, 3), ".") + 1, 8) = "12345678" then
..... do this code ....
End If

--
Regards,
Tom Ogilvy

"james" wrote in message
...
Hello,
I can not seem to figure out the FIND command in VB code. It works

great
in the worksheet. What I have is several hundred cells that start off with

2
to 5 characters then a "." then 8 numbers followed by another "." 3

numbers
then 2 letters (ie.. ABCD.12345678.012AB). I need the information in the
middle, the 12345678 by it's self. I try to use the following code, but it
does not like the FIND portion (Sub or Function not defined error)

If MID(Cells(irow, 3), FIND(".", Cells(irow, 3)) + 1, 8) = "12345678" then
.... do this code ....
End If

The only way I have been able to get the results I need is with the
following:

For i = 2 to 6
x = MID(Cells(irow, 3), i, 1)
If x = Chr(46) then ' the "."
s = i
Exit For
End If
Next
If MID(Cells(irow, 3), s + 1, 8) = "12345678" then
.... do this code ....
End If

This works but I really did not want to search several times on each and
every cell on hundreds of lines.

Any help would be greatly appreicated.

James K.




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 First Non blank cell than find column header and return that value Silver Rose Excel Worksheet Functions 10 April 30th 07 05:56 PM
where to put results of find operation in find and replace functio DEP Excel Worksheet Functions 5 November 15th 06 07:52 PM
Despite data existing in Excel 2002 spreadsheet Find doesn't find AnnieB Excel Discussion (Misc queries) 1 June 16th 06 02:15 AM
How do I find a file/spreadsheet that Excel says is Already open but I can't find it? nwtrader8 Excel Discussion (Misc queries) 5 June 21st 05 02:16 PM
backwards find function to find character in a string of text Ashleigh K. Excel Programming 1 January 14th 04 04:36 PM


All times are GMT +1. The time now is 12:27 AM.

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"