Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default IF(OR) function with text

hello,

I'm trying to get VBA to insert the following formula into Excel,
however, I get a "Expected end of statement error" with all the text
("1", "4", " R", "Error/check") sections in the formula. Would you know
why?

And maybe there's a smarter way to do this?

Range("H2").Formula =
"=IF(OR(LEFT(G2,1)=1,LEFT(G2,1)="1"),VLOOKUP(G 2,[Voucher_03.xls]Sheet1!$A:$B,2,FALSE),
IF(OR(LEFT(G2,1)=4,LEFT(G2,1)="4"),VLOOKUP(G2,[POnumbers_03.xls]Sheet1!$A:$B,2,FALSE),IF(LEFT(G2,2)="
R",VLOOKUP(G2,[POnumbers_03.xls]Sheet1!$A:$B,2,FALSE),
"Error/check")))"

BR,
K.

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,339
Default IF(OR) function with text

Use double quotes i.e. ""1"",""R""

HTH

" wrote:

hello,

I'm trying to get VBA to insert the following formula into Excel,
however, I get a "Expected end of statement error" with all the text
("1", "4", " R", "Error/check") sections in the formula. Would you know
why?

And maybe there's a smarter way to do this?

Range("H2").Formula =
"=IF(OR(LEFT(G2,1)=1,LEFT(G2,1)="1"),VLOOKUP(G 2,[Voucher_03.xls]Sheet1!$A:$B,2,FALSE),
IF(OR(LEFT(G2,1)=4,LEFT(G2,1)="4"),VLOOKUP(G2,[POnumbers_03.xls]Sheet1!$A:$B,2,FALSE),IF(LEFT(G2,2)="
R",VLOOKUP(G2,[POnumbers_03.xls]Sheet1!$A:$B,2,FALSE),
"Error/check")))"

BR,
K.


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default IF(OR) function with text


Hi,

To fix the VBA problem use double quotation marks in your statement, e
(""1"", ""4"", "" R"", ""Error/check"").

re "And maybe there's a smarter way to do this?":
I haven't actually taken the time to completely decipher your formul
as I'm off to bed but at a glance would suggest:
*that you limit the size of your lookup ranges to those rows tha
contain data rather than complete columns to speed the vlookup up (e
by using a "dynamic named range").
*Changing the format of col G to "general" or a some sort of numbe
format so that the "OR(LEFT(G2,1)=1,LEFT(G2,1)="1"),..." etc is no
needed.

hth
Rob Brockett
NZ
Always learning & the best way to learn is to experience..

--
broro18
-----------------------------------------------------------------------
broro183's Profile: http://www.excelforum.com/member.php...fo&userid=3006
View this thread: http://www.excelforum.com/showthread.php?threadid=53369

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default IF(OR) function with text

thanks!

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default IF(OR) function with text


Pleased we could help, thanks for the acknowledgement.

Rob Brockett
NZ
Always learning & the best way to learn is to experience...


--
broro183
------------------------------------------------------------------------
broro183's Profile: http://www.excelforum.com/member.php...o&userid=30068
View this thread: http://www.excelforum.com/showthread...hreadid=533692



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
using a conditional suffix in text function format syntax=text(value,format_text) Brotherharry Excel Worksheet Functions 1 January 13th 09 03:03 PM
Can Text Function change output text color? epiekarc Excel Discussion (Misc queries) 1 December 31st 08 02:58 AM
Advanced text function (combining text) Johan[_2_] Excel Worksheet Functions 2 March 27th 08 10:05 PM
Using Concatenate function to generate text in Text Box Mary S. Charts and Charting in Excel 1 December 14th 05 08:55 PM
Macro or Function to make text size to suite text Length? lbbss Excel Discussion (Misc queries) 4 December 14th 04 07:53 PM


All times are GMT +1. The time now is 02:53 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"