View Single Post
  #6   Report Post  
Posted to microsoft.public.excel.programming
Riyas Majeed Riyas Majeed is offline
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)