Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 48
Default find a "." then

is there a way to search a variable containing "mydoc.doc" for the "." and if
found do the next line i tried

if sel=*.* then

but it doesnt work any ideas

thanks

Rivers
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 396
Default find a "." then

If Instr(yourstring, whatyouwanttosearch) 0 Then

'code in case found

Else

'code in case not found

End if



--
Wigi
http://www.wimgielis.be = Excel/VBA, soccer and music


"Rivers" wrote:

is there a way to search a variable containing "mydoc.doc" for the "." and if
found do the next line i tried

if sel=*.* then

but it doesnt work any ideas

thanks

Rivers

  #3   Report Post  
Posted to microsoft.public.excel.programming
JMB JMB is offline
external usenet poster
 
Posts: 2,062
Default find a "." then

try
If InStr(1, sel, ".", vbTextCompare) 0 Then

you could also use the Like operator, which is closer to what you originally
tried:
If sel Like "*.*" Then

but the like operator depends on the Option Compare statement at the top of
the module (option compare binary is the default). Shouldn't make a
difference searching for period, but is something to keep in mind for the
future.


"Rivers" wrote:

is there a way to search a variable containing "mydoc.doc" for the "." and if
found do the next line i tried

if sel=*.* then

but it doesnt work any ideas

thanks

Rivers

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default find a "." then

As Wigi posted, use the Instr function. However, there may be other ways to
accomplish this depending on what your next lines of code are. Can you tell
us what you are ultimately going to do if you find the "." in the text?

Rick


"Rivers" wrote in message
...
is there a way to search a variable containing "mydoc.doc" for the "." and
if
found do the next line i tried

if sel=*.* then

but it doesnt work any ideas

thanks

Rivers


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 913
Default find a "." then

On Sun, 3 Aug 2008 09:02:00 -0700, Rivers
wrote:

is there a way to search a variable containing "mydoc.doc" for the "." and if
found do the next line i tried

if sel=*.* then

but it doesnt work any ideas

thanks

Rivers


Try this:

Dim sel as String
If InStr(sel, ".")0 Then
' this line is executed if there is a "." in the variable sel
End If

Hope this helps / Lars-Åke


  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 48
Default find a "." then


wow that was fast

guys that worked brilliantly i have another question if your up for it?

how do i remove a section of a string to a point i.e "untitled.bitmap" to
"untitled" i want to look for the "." and delete it plus everything after it.

however the "." can appear multiple times within the string i just need to
delete the first segment i.e

"found.untitled.bitmap" ="found.untitled"

thanks

rivers

"Lars-Ã…ke Aspelin" wrote:

On Sun, 3 Aug 2008 09:02:00 -0700, Rivers
wrote:

is there a way to search a variable containing "mydoc.doc" for the "." and if
found do the next line i tried

if sel=*.* then

but it doesnt work any ideas

thanks

Rivers


Try this:

Dim sel as String
If InStr(sel, ".")0 Then
' this line is executed if there is a "." in the variable sel
End If

Hope this helps / Lars-Ã…ke

  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default find a "." then

Did you mean delete the **last** section (that is what your example shows)?

TheText = "found.untitled.bitmap"
If InStr(TheText, ".") 0 Then
TheNewText = Left(TheText, InStrRev(TheText, ".") - 1)
End If

Rick


"Rivers" wrote in message
...

wow that was fast

guys that worked brilliantly i have another question if your up for it?

how do i remove a section of a string to a point i.e "untitled.bitmap" to
"untitled" i want to look for the "." and delete it plus everything after
it.

however the "." can appear multiple times within the string i just need to
delete the first segment i.e

"found.untitled.bitmap" ="found.untitled"

thanks

rivers

"Lars-Ã…ke Aspelin" wrote:

On Sun, 3 Aug 2008 09:02:00 -0700, Rivers
wrote:

is there a way to search a variable containing "mydoc.doc" for the "."
and if
found do the next line i tried

if sel=*.* then

but it doesnt work any ideas

thanks

Rivers


Try this:

Dim sel as String
If InStr(sel, ".")0 Then
' this line is executed if there is a "." in the variable sel
End If

Hope this helps / Lars-Ã…ke


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" a wildcard as a place marker and "replace" with original va Eric Excel Discussion (Misc queries) 1 January 27th 09 06:00 PM
Excel - Golf - how to display "-2" as "2 Under" or "4"as "+4" or "4 Over" in a calculation cell Steve Kay Excel Discussion (Misc queries) 2 August 8th 08 01:54 AM
find "Cancellation" in column "A" and copy all data from Columns B-F onto another Sheet bjohnson Excel Programming 1 September 20th 07 04:02 PM
HELP on "left","right","find","len","substitute" functions serene83 Excel Discussion (Misc queries) 5 June 27th 06 02:23 AM


All times are GMT +1. The time now is 05:13 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"