VBA Question

G

Guest

Hi,

I need to put the line below in my VBA code but i get error i know that is
because I use the symbole " but i don't know how can i fix it. any help would
be appriciated.

Range("A2").Value =
"=IF(AND(RIGHT(B2,1)="W",LEFT(F2,1)=$A$1),$A$1&"W",IF(AND(RIGHT(B2,1)="G",LEFT(F2,1)=$A$1),$A$1&"G",""))"

Thanks,
 
G

Guest

You need to add extra quotes to let the compiler know that you are using
quotes...

Range("A2").Value =
"=IF(AND(RIGHT(B2,1)=""W"",LEFT(F2,1)=$A$1),$A$1&""W"",IF(AND(RIGHT(B2,1)=""G"",LEFT(F2,1)=$A$1),$A$1&""G"",""""))"

I think I got them all...
 
D

Don Guillett

A little different
=IF(LEFT(F2)=A1,IF(RIGHT(B2)="w",A1&"W",IF(RIGHT(B2)="g",A1&"G","")),"")

Sub ifleft()
Range("c4").Formula = "=IF(LEFT(F2)=A1,IF(RIGHT(B2)=""w""" _
& ",A1&""W"",IF(RIGHT(B2)=""g"",A1&""G"","""")),"""")"
End Sub
 
I

iliace

Call me strange... I like doing it this way:

Range("A2").Value = "=IF(AND(RIGHT(B2,1)=" & Chr(34) & _
"W" & Chr(34) & ",LEFT(F2,1)=$A$1),$A$1&" & Chr(34) & _
"W" & Chr(34) & ",IF(AND(RIGHT(B2,1)=" & Chr(34) & "G" & _
Chr(34) & ",L­EFT(F2,1)=$A$1),$A$1&" & Chr(34) & "G" & _
Chr(34) & "," & Chr(34) & "" & Chr(34) & "))"
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top