Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default *expression* - how to find surrounded string

I would like to hide all rows that do not match a criteria in a specific
column. The criteria though is sometimes "hidden" in a text like
blablakeywordblabla - in this case the keyword is given and should be
identified regardless whether there is blabla around. The kleene stern method
*keyword* does not work, I tried already the following:
If Cells(x, 11).Value = "*erledigt*" Then
Cells(x, 11).EntireRow.Hidden = True
End If
Does somebody know how I could do this?
Thanks
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 793
Default *expression* - how to find surrounded string

Test with Instr() method...
example
Sub t()
tmp = Cells(1, 1)
If InStr("keyword", tmp) Then
Debug.Print "Found"
Else
Debug.Print "Not found"
End If
End Sub

Convert to UPPER if case does not matter...

"Saladin Andreas" wrote:

I would like to hide all rows that do not match a criteria in a specific
column. The criteria though is sometimes "hidden" in a text like
blablakeywordblabla - in this case the keyword is given and should be
identified regardless whether there is blabla around. The kleene stern method
*keyword* does not work, I tried already the following:
If Cells(x, 11).Value = "*erledigt*" Then
Cells(x, 11).EntireRow.Hidden = True
End If
Does somebody know how I could do this?
Thanks

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,441
Default *expression* - how to find surrounded string

Use Like as the comparison, not =

If Cells(x, 11).Value Like "*erledigt*" Then

Though your comparison would work in certain worksheet functions...

HTH,
Bernie
MS Excel MVP


"Saladin Andreas" wrote in
message ...
I would like to hide all rows that do not match a criteria in a specific
column. The criteria though is sometimes "hidden" in a text like
blablakeywordblabla - in this case the keyword is given and should be
identified regardless whether there is blabla around. The kleene stern
method
*keyword* does not work, I tried already the following:
If Cells(x, 11).Value = "*erledigt*" Then
Cells(x, 11).EntireRow.Hidden = True
End If
Does somebody know how I could do this?
Thanks


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,934
Default *expression* - how to find surrounded string

Consider using the Like operator instead of the "equal" operator...

If Cells(x, 11).Value Like "*keyword*" Then

--
Rick (MVP - Excel)


"Saladin Andreas" wrote in
message ...
I would like to hide all rows that do not match a criteria in a specific
column. The criteria though is sometimes "hidden" in a text like
blablakeywordblabla - in this case the keyword is given and should be
identified regardless whether there is blabla around. The kleene stern
method
*keyword* does not work, I tried already the following:
If Cells(x, 11).Value = "*erledigt*" Then
Cells(x, 11).EntireRow.Hidden = True
End If
Does somebody know how I could do this?
Thanks


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,934
Default *expression* - how to find surrounded string

Two things...

1) Uh, you have your arguments reversed...

If InStr(tmp, "keyword") then

2) You don't need to use the UCase function (not the UPPER function; that is
a worksheet function, not a VB one) to perform an case-insensitive search,
InStr can do that via its optional arguments...

If InStr(1, tmp, "keyword", vbTextCompare) then

--
Rick (MVP - Excel)


"Sheeloo" wrote in message
...
Test with Instr() method...
example
Sub t()
tmp = Cells(1, 1)
If InStr("keyword", tmp) Then
Debug.Print "Found"
Else
Debug.Print "Not found"
End If
End Sub

Convert to UPPER if case does not matter...

"Saladin Andreas" wrote:

I would like to hide all rows that do not match a criteria in a specific
column. The criteria though is sometimes "hidden" in a text like
blablakeywordblabla - in this case the keyword is given and should be
identified regardless whether there is blabla around. The kleene stern
method
*keyword* does not work, I tried already the following:
If Cells(x, 11).Value = "*erledigt*" Then
Cells(x, 11).EntireRow.Hidden = True
End If
Does somebody know how I could do this?
Thanks




  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default *expression* - how to find surrounded string

Thank you very much

sometimes it is so easy, with the like operator it just works - wonderful

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
How to evaluate string form of numeric expression in VBA? [email protected] Excel Programming 6 December 31st 07 05:23 PM
regular expression parse string Perl $1 VBScript.RegExp [email protected][_2_] Excel Programming 7 July 14th 07 04:12 PM
Find Row from MAX expression Dave Birley Excel Programming 6 May 21st 07 01:04 PM
Run/Execute string expression Hammas Excel Programming 0 September 29th 05 05:13 AM
Giving the String expression for Numeric Values.... Arijit Chatterjee Excel Programming 2 November 19th 03 10:57 AM


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