473,387 Members | 1,693 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Urgent help I want my VB script to insert an excell formula in a specified excel cell

2
The formula is: =IF(Input!R703<0,HPLNK(Input!R703,Entity,Category6 ,$A$677&"."&$A703,N$3,Frequency1,Application1),HPL NK(Input!R703,Entity,Category6,"P1709"&"."&$A703,N $3,Frequency1,Application1))
This works fine is excel so I know the syntax is ok with Excel

When I try this in VB:
Range("N679").Select
Selection.Formula = "=IF(Input!R679<0,HPLNK(Input!R679,Entity,Category 6,$A$677&"."&$A679,N$3,Frequency1,Application1),HP LNK(Input!R679,Entity,Category6,"P1709"&"."&$A679, N$3,Frequency1,Application1))"

I get a compile error with syntax

Can anyone help?
Dec 23 '10 #1
3 1609
code green
1,726 Expert 1GB
Try writing the formula to the cell as a string.
Expand|Select|Wrap|Line Numbers
  1. Range("N679") = "IF(Input!R703<0,HPLNK(Input!R703,Entity,Category6 ,$A$677&"."&$A703,N$3,Frequency1,Application1),HPL NK(Input!R703,Entity,Category6,"P1709"&"."&$A703,N $3,Frequency1,Application1))"
The code I've posted won't work without modification.
But I have written formulas as strings to Excel with no problems.
Dec 24 '10 #2
Rabbit
12,516 Expert Mod 8TB
You didn't escape the double quotes in your string.
Error> "a & "b" & c"
Correct> "a & ""b"" & c"
Dec 24 '10 #3
nicoPK
2
spot on Rabbit - thanks for your help
Dec 25 '10 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Alan | last post by:
I'm just starting out in C# so this is really a basic question. I have an Excel cell reference for which I need to generate offsets It seems to me that the best way is to start off with a string...
1
by: sudhaoncyberworld | last post by:
I have scenario like below, in table we have insert row & in row we have insert cell, but i need to insert an table element in td, Here in td i have tbl1 & tbl2 as child and now i want to insert...
0
by: nickyr | last post by:
Hi, I want to get the data from one excel cell to a textbox. Nothing more than that. What I have now is this: Dim myxl As Object Dim strdata As String myxl = GetObject ("d:\test.xls")
0
by: shkamat | last post by:
Hi I have a peculiar problem. I generate an excel sheet through ASP page, using table to take the formulas. One of my cell contains this : <tr> <td valign="top" width="2%">...
0
by: payelit21 | last post by:
Hi Friends, can any body help me to convert excel cell from date to general and passinfg value to min value and max value of axis in chart through VB. Thanks Payel
1
by: datttanand | last post by:
how to add drop down list in excel cell using javascript code?
14
by: veer | last post by:
can any one help by providing the method inserting the records in excel file because i created it all it works fine but i have no idea about how to insert new records in the existing excel file....
1
by: ronakinuk | last post by:
how to insert multiple rows in excel using vba how to insert multiple rows in excel using vba how to insert multiple rows in excel using vba
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.