ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   How do I use variables in Excel? (https://www.excelbanter.com/excel-discussion-misc-queries/36285-how-do-i-use-variables-excel.html)

XUT67

How do I use variables in Excel?
 
How Can I accomplish this, say this is field A1:

The %product% only costs %price%. Order today, we only have %qty% left!

--------------
Obvoiusly the words enclosed in % % are the variables that I want replaced.
Is there way that I can make fields B, C, and D equal the corresponding variables?

For example,

B1= Dog collar
C1= $9.99
D1= 20

So then A1 becomes:

The dog collar only costs $9.99. Order today, we only have 20 left!

I'm open to trying ANY method that can allow me to use variables in Excel.

Thanks.

Dave O

Yes- check out Named Ranges in the Help feature. I'm not sure if Excel
will allow you to call the range %Product%, but it will definitely
allow you to call it Product.

Once you have named the ranges your formula would be
="The " & Product & " only costs " & Price &". Order today, we only
have " & Qty & " left!"


Dave O

Click Insert Name Define and a window appears. Type your variable
name in the top and mouse click the appropriate cell.


XUT67

Quote:

Originally Posted by Dave O
Click Insert Name Define and a window appears. Type your variable
name in the top and mouse click the appropriate cell.

Ok, I got it done but now I'm trying to save it as a csv file without saving the coulmn that has the references.

So I looked online and found out about referencing from another worksheet.
Example:

=(Sheet2!A1:A8)

The problem is, the field will only show A1.

It seems that I need to add a math function:

=SUM(Sheet2!A1:A8)

In order for it to work. But I don't need math, I just need to text. How do you reference a range of text from a different worksheet?

Thanks!

CyberTaz

Not sure I'm clear on the issue, but since nobody has responded I'll give it
a shot. Post back with more info if this doesn't hit the mark.

When you create the link (=Sheet2!A1:A8), the entire content of all 8 cells
*does not* get entered into the *one* cell containing the formula. On the
sheet where you created the link formula you need to drag the fill handle
(small nub at lower right corner of cell selector) right as many columns as
the data occupies on the source sheet (& then down as many rows as the data
occupies on the source sheet if more than one record) to display all the
data. The only content that gets copied out to your csv is what is displayed
on your sheet when you create the file.

FWIW, when I do something like this I usually just use =Sheet1!A1 as my
formula & then use the fill handle to copy it over & down to the necessary
number of columns & rows.

HTH |:)

"XUT67" wrote:


Dave O Wrote:
Click Insert Name Define and a window appears. Type your variable
name in the top and mouse click the appropriate cell.


Ok, I got it done but now I'm trying to save it as a csv file without
saving the coulmn that has the references.

So I looked online and found out about referencing from another
worksheet.
Example:

=(Sheet2!A1:A8)

The problem is, the field will only show A1.

It seems that I need to add a math function:

=SUM(Sheet2!A1:A8)

In order for it to work. But I don't need math, I just need to text.
How do you reference a range of text from a different worksheet?

Thanks!


--
XUT67



All times are GMT +1. The time now is 08:21 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com