#1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 281
Default VBA Question


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,
--
Farhad Hodjat
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 5,939
Default VBA Question

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...
--
HTH...

Jim Thomlinson


"Farhad" wrote:


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,
--
Farhad Hodjat

  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 10,124
Default VBA Question

A little different
=IF(LEFT(F2)=A1,IF(RIGHT(B2)="w",A1&"W",IF(RIGHT(B 2)="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

--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"Farhad" wrote in message
...

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,
--
Farhad Hodjat


  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 229
Default VBA Question

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) & "))"

On Sep 11, 4:30 pm, Farhad wrote:
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",L*EFT(F2,1)=$A$1),$A$1&"G" ,""))"

Thanks,
--
Farhad Hodjat



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
IF Question Carl Excel Worksheet Functions 2 August 17th 06 04:38 PM
Question odditie New Users to Excel 6 August 4th 06 06:55 AM
Newbie Question - Subtraction Formula Question [email protected] Excel Discussion (Misc queries) 3 May 5th 06 05:50 PM
The question is an excel question that I need to figure out howto do in excel. Terry Excel Worksheet Functions 3 January 23rd 06 06:22 PM
IF Question Joe Excel Worksheet Functions 3 February 14th 05 11:54 PM


All times are GMT +1. The time now is 11:30 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"