PC Review


Reply
Thread Tools Rate Thread

comparing strings

 
 
oercim
Guest
Posts: n/a
 
      27th Aug 2012
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.
 
Reply With Quote
 
 
 
 
Claus Busch
Guest
Posts: n/a
 
      27th Aug 2012
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
 
Reply With Quote
 
 
 
 
oercim
Guest
Posts: n/a
 
      27th Aug 2012
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.
 
Reply With Quote
 
Claus Busch
Guest
Posts: n/a
 
      27th Aug 2012
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
 
Reply With Quote
 
oercim
Guest
Posts: n/a
 
      27th Aug 2012
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


 
Reply With Quote
 
Riyas Majeed
Guest
Posts: n/a
 
      27th Aug 2012
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 codeas below

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


(Remove the " " for TRUE)
 
Reply With Quote
 
Riyas Majeed
Guest
Posts: n/a
 
      27th Aug 2012
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 codeas below

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


(Remove the " " for TRUE)
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Strings Strings Strings from sql ds. =?Utf-8?B?Q2hyaXN0b3BoZXI=?= Microsoft C# .NET 5 10th Dec 2004 01:20 AM
Make Word displays strings of text, not strings of code =?Utf-8?B?WGVybw==?= Microsoft Word Document Management 2 9th Dec 2004 11:35 AM
Finding strings within strings =?Utf-8?B?Um9k?= Microsoft Excel Programming 1 2nd Dec 2003 06:34 PM
Finding strings within strings Rod Microsoft Excel Programming 1 2nd Dec 2003 06:19 PM
PN: Converting C Strings to managed strings Peter Nolan Microsoft VC .NET 0 21st Nov 2003 12:01 AM


Features
 

Advertising
 

Newsgroups
 


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