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

Hello, I have a problem. I want to compare string in vba however I couldn't manage.My statemets are like below:


If Sheets("Sayfa1").Cells(1, 1) ="TRUE" Then
Sheets("Sayfa1").Cells(1, 2) = 1
End If


These statements doesnt give error but it doesnt also print "1" cell(1,2) even the cell(1,1)="TRUE.

How can I do this? Thanks a lot.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,872
Default comparing strings

Hi,

Am Mon, 27 Aug 2012 05:49:55 -0700 (PDT) schrieb oercim:

If Sheets("Sayfa1").Cells(1, 1) ="TRUE" Then
Sheets("Sayfa1").Cells(1, 2) = 1
End If


try:
With Sheets("Sayfa1")
.Cells(1, 2) = -(Cells(1, 1) = True)
End With


Regards
Claus Busch
--
Win XP PRof SP2 / Vista Ultimate SP2
Office 2003 SP2 /2007 Ultimate SP2
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 51
Default comparing strings

Thanks a lot for the answer. Hut I couldn't understnad the statements. For example

If Sheets("Sayfa1").Cells(1, 1) ="JOHN" Then
Sheets("Sayfa1").Cells(1, 2) = $500
End If

How will I do this "with- end with" statements. Thank a lot.
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,872
Default comparing strings

Hi,

Am Mon, 27 Aug 2012 06:40:31 -0700 (PDT) schrieb oercim:

If Sheets("Sayfa1").Cells(1, 1) ="JOHN" Then
Sheets("Sayfa1").Cells(1, 2) = $500
End If

How will I do this "with- end with" statements. Thank a lot.


try:
With Sheets("Sayfa1")
If .Cells(1, 1) = "JOHN" Then
.Cells(1, 2) = 500
End If
End With


Regards
Claus Busch
--
Win XP PRof SP2 / Vista Ultimate SP2
Office 2003 SP2 /2007 Ultimate SP2
  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 51
Default comparing strings

27 Ağustos 2012 Pazartesi 16:50:05 UTC+3 tarihinde Claus Busch yazdı:
Hi,



Am Mon, 27 Aug 2012 06:40:31 -0700 (PDT) schrieb oercim:



If Sheets("Sayfa1").Cells(1, 1) ="JOHN" Then


Sheets("Sayfa1").Cells(1, 2) = $500


End If




How will I do this "with- end with" statements. Thank a lot.




try:

With Sheets("Sayfa1")

If .Cells(1, 1) = "JOHN" Then

.Cells(1, 2) = 500

End If

End With





Regards

Claus Busch

--

Win XP PRof SP2 / Vista Ultimate SP2

Office 2003 SP2 /2007 Ultimate SP2




  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default comparing strings

On Monday, August 27, 2012 6:19:55 PM UTC+5:30, oercim wrote:
Hello, I have a problem. I want to compare string in vba however I couldn't manage.My statemets are like below: If Sheets("Sayfa1").Cells(1, 1) ="TRUE" Then Sheets("Sayfa1").Cells(1, 2) = 1 End If These statements doesnt give error but it doesnt also print "1" cell(1,2) even the cell(1,1)="TRUE. How can I do this? Thanks a lot.


Hi,

from TRUE is a keyword. So if you want to use TRUE as keyword as such, in the sheet u have to write 'TRUE (prefix a ' )

but if you are using TRUE as a Boolean keyword itself, then modify the code as below

If Sheets("Sayfa1").Cells(1, 1) = True Then
Sheets("Sayfa1").Cells(1, 2) = 1
End If


(Remove the " " for TRUE)
  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default comparing strings

On Monday, August 27, 2012 6:19:55 PM UTC+5:30, oercim wrote:
Hello, I have a problem. I want to compare string in vba however I couldn't manage.My statemets are like below: If Sheets("Sayfa1").Cells(1, 1) ="TRUE" Then Sheets("Sayfa1").Cells(1, 2) = 1 End If These statements doesnt give error but it doesnt also print "1" cell(1,2) even the cell(1,1)="TRUE. How can I do this? Thanks a lot.


Hi,

TRUE is a reserved keyword. If you want to use TRUE simply as a string, then in the sheet u have to write 'TRUE (prefix a ' )

but if you are using TRUE as a Boolean keyword itself, then modify the code as below

If Sheets("Sayfa1").Cells(1, 1) = True Then
Sheets("Sayfa1").Cells(1, 2) = 1
End If


(Remove the " " for TRUE)
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
Comparing text strings Comparing columns with text Excel Worksheet Functions 5 November 28th 09 07:43 PM
comparing text strings CG Rosén Excel Programming 2 September 24th 07 09:08 AM
problem with comparing strings in VBA [email protected] Excel Discussion (Misc queries) 2 June 25th 07 11:16 PM
Comparing Formula Strings after Row has been Inserted ExcelMonkey Excel Programming 3 May 7th 07 08:32 PM
Comparing slightly different strings theDude[_18_] Excel Programming 0 July 30th 05 12:55 AM


All times are GMT +1. The time now is 11:52 PM.

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"