Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 69
Default VB programming

Hello,

I want to run a macro such that when I press on a toggle button, if the
state is true then I would like to insert the following formula into a cell

=IF(ISERROR(OR(SEARCH("a",$B$10,1)=1,SEARCH("a",$B $10,1)=4)),"Random",(VLOOKUP($B$10,'MC DATA'!$B$6:$C$54,2,FALSE)/(($B$12+18)/12)*Production_Rate)*60).

This is what I have tried:
worksheets("Simple Cost Analysis").Range("G6").Formula =
"=IF(ISERROR(OR(SEARCH("a",$B$10,1)=1,SEARCH("a",$ B$10,1)=4)),"Random",(VLOOKUP($B$10,'MC DATA'!$B$6:$C$54,2,FALSE)/(($B$12+18)/12)*Production_Rate)*60)"

But I get a syntax error due to the " within the formula.

Any idea how to solve this?

Thank you in advance

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 91
Default VB programming

Within the formula itself (not counting the quotes around the formula
used by the .Formula function) double up the quotes. For example,
notice the quotes around "text" versus the single quotes around the
entire formula:

range("A1").Formula = "=search(""text"",$B$1)"

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,202
Default VB programming

You have to double up the quote marks **within** the String value in order
to place a single quote mark there (otherwise VBA tries to use the internal
single quote marks as the end delimiter of the String constant and gets
confused. Try it this way...

Worksheets("Simple Cost Analysis").Range("G6").Formula =
"=IF(ISERROR(OR(SEARCH(""a"",$B$10,1)=1,SEARCH(""a "",$B$10,1)=4)),""Random"",(VLOOKUP($B$10,'MC
DATA'!$B$6:$C$54,2,FALSE)/(($B$12+18)/12)*Production_Rate)*60)"

Rick


"Nelson" wrote in message
...
Hello,

I want to run a macro such that when I press on a toggle button, if the
state is true then I would like to insert the following formula into a
cell

=IF(ISERROR(OR(SEARCH("a",$B$10,1)=1,SEARCH("a",$B $10,1)=4)),"Random",(VLOOKUP($B$10,'MC
DATA'!$B$6:$C$54,2,FALSE)/(($B$12+18)/12)*Production_Rate)*60).

This is what I have tried:
worksheets("Simple Cost Analysis").Range("G6").Formula =
"=IF(ISERROR(OR(SEARCH("a",$B$10,1)=1,SEARCH("a",$ B$10,1)=4)),"Random",(VLOOKUP($B$10,'MC
DATA'!$B$6:$C$54,2,FALSE)/(($B$12+18)/12)*Production_Rate)*60)"

But I get a syntax error due to the " within the formula.

Any idea how to solve this?

Thank you in advance


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,939
Default VB programming

Double up your quotes (that is a directive to the compiler that you want to
use quotes in your string)

=IF(ISERROR(OR(SEARCH(""a"",$B$10,1)=1,SEARCH(""a" ",$B$10,1)=4)),""Random"",(VLOOKUP($B$10,'MC
DATA'!$B$6:$C$54,2,FALSE)/(($B$12+18)/12)*Production_Rate)*60)
--
HTH...

Jim Thomlinson


"Nelson" wrote:

Hello,

I want to run a macro such that when I press on a toggle button, if the
state is true then I would like to insert the following formula into a cell

=IF(ISERROR(OR(SEARCH("a",$B$10,1)=1,SEARCH("a",$B $10,1)=4)),"Random",(VLOOKUP($B$10,'MC DATA'!$B$6:$C$54,2,FALSE)/(($B$12+18)/12)*Production_Rate)*60).

This is what I have tried:
worksheets("Simple Cost Analysis").Range("G6").Formula =
"=IF(ISERROR(OR(SEARCH("a",$B$10,1)=1,SEARCH("a",$ B$10,1)=4)),"Random",(VLOOKUP($B$10,'MC DATA'!$B$6:$C$54,2,FALSE)/(($B$12+18)/12)*Production_Rate)*60)"

But I get a syntax error due to the " within the formula.

Any idea how to solve this?

Thank you in advance

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 69
Default VB programming

Thank you to all

"Rick Rothstein (MVP - VB)" wrote:

You have to double up the quote marks **within** the String value in order
to place a single quote mark there (otherwise VBA tries to use the internal
single quote marks as the end delimiter of the String constant and gets
confused. Try it this way...

Worksheets("Simple Cost Analysis").Range("G6").Formula =
"=IF(ISERROR(OR(SEARCH(""a"",$B$10,1)=1,SEARCH(""a "",$B$10,1)=4)),""Random"",(VLOOKUP($B$10,'MC
DATA'!$B$6:$C$54,2,FALSE)/(($B$12+18)/12)*Production_Rate)*60)"

Rick


"Nelson" wrote in message
...
Hello,

I want to run a macro such that when I press on a toggle button, if the
state is true then I would like to insert the following formula into a
cell

=IF(ISERROR(OR(SEARCH("a",$B$10,1)=1,SEARCH("a",$B $10,1)=4)),"Random",(VLOOKUP($B$10,'MC
DATA'!$B$6:$C$54,2,FALSE)/(($B$12+18)/12)*Production_Rate)*60).

This is what I have tried:
worksheets("Simple Cost Analysis").Range("G6").Formula =
"=IF(ISERROR(OR(SEARCH("a",$B$10,1)=1,SEARCH("a",$ B$10,1)=4)),"Random",(VLOOKUP($B$10,'MC
DATA'!$B$6:$C$54,2,FALSE)/(($B$12+18)/12)*Production_Rate)*60)"

But I get a syntax error due to the " within the formula.

Any idea how to solve this?

Thank you in advance



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
VBA Programming. RSteph Excel Programming 3 October 30th 06 08:23 PM
new to VBA programming [email protected] Excel Programming 14 September 1st 06 03:02 AM
VBA programming kush28 Excel Programming 1 February 9th 06 08:05 AM
Programming lag.. Ernst Guckel[_3_] Excel Programming 0 June 8th 04 03:37 AM
Programming Help Nate[_5_] Excel Programming 6 May 21st 04 08:08 PM


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