Selasa, 27 Maret 2012

Re: [ExcelVBA] Using Literals in Formulas

 

Hello,
 
You can not create a variable that is an address, like A1. Define the name and what the variable will be in V2003, Insert/Name/Define/ where you can put in the variable name ie. Apple and refers to: "Apple".
 
Thanks,
David


________________________________
From: mickey11030 <mickey11030@yahoo.com>
To: ExcelVBA@yahoogroups.com
Sent: Tuesday, March 27, 2012 10:12 AM
Subject: [ExcelVBA] Using Literals in Formulas


 

Assume Col A has a list of fruit names, and A1 contains "Apples". I can use the following code
Range("B1").Value = "= ""Ripe "" & A1 & "" Cheap"""
to get "Ripe " & A1 & " Cheap" which displays as Ripe Apples Cheap in B1. The contents of B1 can be copied down Col B giving Ripe Watermelon Cheap, etc. in Col B.

But suppose instead of Ripe I have a long string. I'd like to define a variable, S1 to be that string, and enter something like "= S1 & A1 & ""Cheap""" into B1, but I can't figure out how to do that. When I finally got the quotation marks right to avoid a syntax error, S1, not the literal it represents, was entered and that was flagged as a #Name error.

I realize I could enter that long literal into a cell, and simply reference that cell, but I wonder if there is any way other than that.

Thanks in advance

[Non-text portions of this message have been removed]

__._,_.___
Recent Activity:
----------------------------------
Be sure to check out TechTrax Ezine for many, free Excel VBA articles! Go here: http://www.mousetrax.com/techtrax to enter the ezine, then search the ARCHIVES for EXCEL VBA.

----------------------------------
Visit our ExcelVBA group home page for more info and support files:
http://groups.yahoo.com/group/ExcelVBA

----------------------------------
More free tutorials and resources available at:
http://www.mousetrax.com

----------------------------------
.

__,_._,___

Tidak ada komentar:

Posting Komentar