Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 87
Default Comparison operator

Hi...

My code is:

If Cells(rw, colno).Value = "US" Or _
Cells(rw, colno).Value = "AI" Then
With Cells(rw, colno)

If UserForm1.ch_sensrtype_d.Value = False Then
.Value = UserForm1.sensrtype.Value
Else
.Value = sensrtype_d
End If
ENd IF

In the line
Cells(rw, colno).Value = "AI", I am comapring cell value with "AI".
However, here I want to search if any part of the cell contains "AI". Measn,
if my cell has value "AIT", then also this statement should become true.

I tried writing "*" & "AI" & "*" but it doesnt work. How can I do this?

Regards,

Pawan
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,593
Default Comparison operator


If Cells(rw, colno).Value = "US" Or _
Cells(rw, colno).Value Like "*AI*" Then


--
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)

"Pawan" wrote in message
...
Hi...

My code is:

If Cells(rw, colno).Value = "US" Or _
Cells(rw, colno).Value = "AI" Then
With Cells(rw, colno)

If UserForm1.ch_sensrtype_d.Value = False Then
.Value = UserForm1.sensrtype.Value
Else
.Value = sensrtype_d
End If
ENd IF

In the line
Cells(rw, colno).Value = "AI", I am comapring cell value with "AI".
However, here I want to search if any part of the cell contains "AI".
Measn,
if my cell has value "AIT", then also this statement should become true.

I tried writing "*" & "AI" & "*" but it doesnt work. How can I do this?

Regards,

Pawan



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 87
Default Comparison operator

Thanks Bob...

I have onem ore doubt in this. My macro is searching for "US" (i.e.
Uppercase). If there is "us" in some cells, its not working. Can we make it
work?

Regards,
Pawan

"Bob Phillips" wrote:


If Cells(rw, colno).Value = "US" Or _
Cells(rw, colno).Value Like "*AI*" Then


--
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)

"Pawan" wrote in message
...
Hi...

My code is:

If Cells(rw, colno).Value = "US" Or _
Cells(rw, colno).Value = "AI" Then
With Cells(rw, colno)

If UserForm1.ch_sensrtype_d.Value = False Then
.Value = UserForm1.sensrtype.Value
Else
.Value = sensrtype_d
End If
ENd IF

In the line
Cells(rw, colno).Value = "AI", I am comapring cell value with "AI".
However, here I want to search if any part of the cell contains "AI".
Measn,
if my cell has value "AIT", then also this statement should become true.

I tried writing "*" & "AI" & "*" but it doesnt work. How can I do this?

Regards,

Pawan




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,593
Default Comparison operator

If LCase(Cells(rw, colno).Value) = "us" Or _
Cells(rw, colno).Value Like "*AI*" Then

this will work for us, US, Us, or uS, that is it is non case-sensitive.

--
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)

"Pawan" wrote in message
...
Thanks Bob...

I have onem ore doubt in this. My macro is searching for "US" (i.e.
Uppercase). If there is "us" in some cells, its not working. Can we make
it
work?

Regards,
Pawan

"Bob Phillips" wrote:


If Cells(rw, colno).Value = "US" Or _
Cells(rw, colno).Value Like "*AI*" Then


--
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my
addy)

"Pawan" wrote in message
...
Hi...

My code is:

If Cells(rw, colno).Value = "US" Or _
Cells(rw, colno).Value = "AI" Then
With Cells(rw, colno)

If UserForm1.ch_sensrtype_d.Value = False Then
.Value = UserForm1.sensrtype.Value
Else
.Value = sensrtype_d
End If
ENd IF

In the line
Cells(rw, colno).Value = "AI", I am comapring cell value with "AI".
However, here I want to search if any part of the cell contains "AI".
Measn,
if my cell has value "AIT", then also this statement should become
true.

I tried writing "*" & "AI" & "*" but it doesnt work. How can I do this?

Regards,

Pawan






  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 87
Default Comparison operator

Great.. Thanks Bob..! :-)

"Bob Phillips" wrote:

If LCase(Cells(rw, colno).Value) = "us" Or _
Cells(rw, colno).Value Like "*AI*" Then

this will work for us, US, Us, or uS, that is it is non case-sensitive.

--
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)

"Pawan" wrote in message
...
Thanks Bob...

I have onem ore doubt in this. My macro is searching for "US" (i.e.
Uppercase). If there is "us" in some cells, its not working. Can we make
it
work?

Regards,
Pawan

"Bob Phillips" wrote:


If Cells(rw, colno).Value = "US" Or _
Cells(rw, colno).Value Like "*AI*" Then


--
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my
addy)

"Pawan" wrote in message
...
Hi...

My code is:

If Cells(rw, colno).Value = "US" Or _
Cells(rw, colno).Value = "AI" Then
With Cells(rw, colno)

If UserForm1.ch_sensrtype_d.Value = False Then
.Value = UserForm1.sensrtype.Value
Else
.Value = sensrtype_d
End If
ENd IF

In the line
Cells(rw, colno).Value = "AI", I am comapring cell value with "AI".
However, here I want to search if any part of the cell contains "AI".
Measn,
if my cell has value "AIT", then also this statement should become
true.

I tried writing "*" & "AI" & "*" but it doesnt work. How can I do this?

Regards,

Pawan








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
Text "comparison" operator for "contains" used in an "IF" Function Pawaso Excel Worksheet Functions 4 April 4th 23 11:35 AM
Comparison Operator "" NOT "=" monir Excel Discussion (Misc queries) 4 October 22nd 07 02:42 AM
Complex comparison of Columns of Data: Extracting unique records after comparison on 4 levels ap Excel Programming 2 January 23rd 07 10:12 AM
Adding a comparison Operator button on a toolbar Teacher in Need Excel Discussion (Misc queries) 1 October 4th 06 01:08 AM
"IN" comparison operator Jared Excel Programming 1 January 24th 05 04:29 PM


All times are GMT +1. The time now is 09:54 AM.

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

About Us

"It's about Microsoft Excel"