Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Visual Basic > VB 6 Visual Basic 6 > Beginning VB 6
|
Beginning VB 6 For coders who are new to Visual Basic, working in VB version 6 (not .NET).
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Beginning VB 6 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 June 10th, 2008, 05:36 AM
Registered User
 
Join Date: Jun 2008
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default Translating WorkSheet Formula in VBA

Hello,

I have the following formula in a cell in my spreadsheet:
Code:
=IF(B1726="", "", B1726 & " (version: " & F1726 & ")")
... which I want to automate in VBA.

I've tried:
Code:
ActiveCell.Formula = "=IF(B1726="", "", B1726 & " (version: " & F1726 & ")")
but it doesn't work.

Am not sure how to translate from one to the other.

Thank you in advance for any help ...

Andy :)

 
Old June 10th, 2008, 12:16 PM
Friend of Wrox
 
Join Date: Nov 2004
Posts: 1,621
Thanks: 1
Thanked 3 Times in 3 Posts
Default

try
Code:
ActiveCell.Formula = "=IF(B1726="""", """", B1726 & "" (version: "" & F1726 & "")"")"
Every place you want a " to appear in the string that gets installed as the formula, use "". Just one doublequote [DQ] by itself ends the interpreter reading your typing as a literal string. Two DQs in a row are interpreted as one DQ in the string you are creating.
 
Old June 11th, 2008, 04:13 AM
Registered User
 
Join Date: Jun 2008
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Understood - thank you :)






Similar Threads
Thread Thread Starter Forum Replies Last Post
Excel formula not working in vba yogeshyl Excel VBA 2 December 12th, 2007 02:27 AM
Excel formula not working in VBA yogeshyl Excel VBA 2 July 19th, 2007 03:57 AM
inserting worksheet into an OLE field with VBA Mihai B Excel VBA 2 January 21st, 2005 06:50 AM
inserting worksheet into an OLE field with VBA Mihai B Access VBA 0 November 23rd, 2004 10:28 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.