Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,510
Default Compare cell value with string

When you use not equal you have to use and. With Or what you are saying is if
not equal to one or not equal to the other therefore so long as one is not
equal then it is true.

If (Cells(loop_counter, "B").Value < "SoftwaInternal" and
Cells(loop_counter, "B").Value < "SoftwaTest Fixed Fee") Then

--
Regards,

OssieMac


"Shahriar Nour Khondokar" wrote:

Hi all
I am trying to compare (and identify) the values in a column with 2 strings.
i am using the following code:
If (Cells(loop_counter, "B").Value = "SoftwaInternal" Or
Cells(loop_counter, "B").Value = "SoftwaTest Fixed Fee") Then

...
End If
'loop_counter' is a variable that has been declared.
This piece of code does its job and identifies cell in column-B that have
"SoftwaInternal" and "SoftwaTest Fixed Fee" as value.

But when i try to use the code below to identify the cells that do NOT have
"SoftwaInternal" and "SoftwaTest Fixed Fee" as Value, it is not working:
If (Cells(loop_counter, "B").Value < "SoftwaInternal" Or
Cells(loop_counter, "B").Value < "SoftwaTest Fixed Fee") Then

...
End If

Can someone please help me understand why is this not working and what can i
use to get the desired result?

Thanks for you help.

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Compare cell value with string

Thanks all for your help!

It was a logic problem as opposed to a syntactical problem; i had to replace
the OR with AND.
I am new to VBA and still need to gain confidence with the syntax :-)

"OssieMac" wrote:

When you use not equal you have to use and. With Or what you are saying is if
not equal to one or not equal to the other therefore so long as one is not
equal then it is true.

If (Cells(loop_counter, "B").Value < "SoftwaInternal" and
Cells(loop_counter, "B").Value < "SoftwaTest Fixed Fee") Then

--
Regards,

OssieMac


"Shahriar Nour Khondokar" wrote:

Hi all
I am trying to compare (and identify) the values in a column with 2 strings.
i am using the following code:
If (Cells(loop_counter, "B").Value = "SoftwaInternal" Or
Cells(loop_counter, "B").Value = "SoftwaTest Fixed Fee") Then

...
End If
'loop_counter' is a variable that has been declared.
This piece of code does its job and identifies cell in column-B that have
"SoftwaInternal" and "SoftwaTest Fixed Fee" as value.

But when i try to use the code below to identify the cells that do NOT have
"SoftwaInternal" and "SoftwaTest Fixed Fee" as Value, it is not working:
If (Cells(loop_counter, "B").Value < "SoftwaInternal" Or
Cells(loop_counter, "B").Value < "SoftwaTest Fixed Fee") Then

...
End If

Can someone please help me understand why is this not working and what can i
use to get the desired result?

Thanks for you help.

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
Compare cell value with string macropod[_2_] Excel Programming 0 May 30th 09 07:40 AM
Compare cell value with string Normek Excel Programming 0 May 30th 09 07:40 AM
Compare cell value to items in string PamG[_2_] Excel Programming 2 October 3rd 08 06:11 PM
Compare text string of a cell in Column A VS another cell in Colum Tan Excel Discussion (Misc queries) 1 August 1st 07 09:03 AM
Compare String in Cell to an Array jbtenor1 Excel Programming 3 March 29th 06 02:36 PM


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