Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Microsoft Office > Excel VBA > Excel VBA
|
Excel VBA Discuss using VBA for Excel programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Excel VBA section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old July 19th, 2007, 02:30 AM
Authorized User
 
Join Date: Apr 2007
Posts: 41
Thanks: 0
Thanked 0 Times in 0 Posts
Default Excel formula not working in VBA

I want to use the following excel formula in VBA

=IF(C3=0,"Nil Forecast",IF(E3=0,"Nil Sale",F3/C3))

Actually i am trying to assign the formula to a cell in excel using VBA. But,When i use text strings i.e "Nil Forecast" & "Nil Sale" in the formula the VBA does not understand.

And when i replace the text strings with a reference cell, it works.

Please give me solution for this.

Yogesh

Yogesh
__________________
Yogesh
 
Old July 19th, 2007, 03:40 AM
Friend of Wrox
 
Join Date: Sep 2005
Posts: 812
Thanks: 1
Thanked 53 Times in 49 Posts
Default

Try using this

ActiveCell.Formula = "=IF(C3=0," & Chr(34) & "Nil Forecast" & Chr(34) & ",IF(E3=0," & Chr(34) & "Nil Sale" & Chr(34) & ",F3/C3))"


Cheers
Shasur

http://www.dotnetdud.blogspot.com
 
Old July 19th, 2007, 03:57 AM
Authorized User
 
Join Date: Apr 2007
Posts: 41
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks. I've been trying since yesterday, the solution given by you is working. Thanks again.

Yogesh

Yogesh





Similar Threads
Thread Thread Starter Forum Replies Last Post
Translating WorkSheet Formula in VBA AndyL Beginning VB 6 2 June 11th, 2008 04:13 AM
Excel formula not working in vba yogeshyl Excel VBA 2 December 12th, 2007 02:27 AM
Excel vba query not working, pls help me. kavisundar SQL Language 0 May 16th, 2007 10:14 AM
why this formula pssing is not working? ceema Crystal Reports 1 April 12th, 2006 06:15 AM
Problems introducing a formula using VBA mariona_cid Excel VBA 0 June 1st, 2004 07:01 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.