ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Variable in string (https://www.excelbanter.com/excel-discussion-misc-queries/67478-variable-string.html)

DevinC

Variable in string
 

Hello, is it possible to create a variable within a string of text in a
cell ?

For example,

Variable = YEAR
YEAR = 2006
Data in cell = "Now, we're in YEAR."

will then make Excel recognize the text, YEAR, as a variable and will
appropriately insert the value there, as :

"Now, we're in 2006."

Is this possible to do in Excel?

Thanks,

Devin


--
DevinC
------------------------------------------------------------------------
DevinC's Profile: http://www.excelforum.com/member.php...o&userid=22739
View this thread: http://www.excelforum.com/showthread...hreadid=505186


Norman Jones

Variable in string
 
Hi Devin,

In Excel:

A1: 2006
B1 ="Now, we're in " & A1 & "."

In VBA:

Dim sYear As String

sYear = 2006

Range("A1").Value = "Now, we're in " & Year & "."



---
Regards,
Norman


"DevinC" wrote in
message ...

Hello, is it possible to create a variable within a string of text in a
cell ?

For example,

Variable = YEAR
YEAR = 2006
Data in cell = "Now, we're in YEAR."

will then make Excel recognize the text, YEAR, as a variable and will
appropriately insert the value there, as :

"Now, we're in 2006."

Is this possible to do in Excel?

Thanks,

Devin


--
DevinC
------------------------------------------------------------------------
DevinC's Profile:
http://www.excelforum.com/member.php...o&userid=22739
View this thread: http://www.excelforum.com/showthread...hreadid=505186




Broadband Al

Variable in string
 
Sounds like you need the CONCATENATE function. Cell formula should be:
=concatenate("Now we're in "&YEAR)
This assumes you have named a cell "YEAR". If not, replace YEAR with your
cell ref.

Al

"DevinC" wrote:


Hello, is it possible to create a variable within a string of text in a
cell ?

For example,

Variable = YEAR
YEAR = 2006
Data in cell = "Now, we're in YEAR."

will then make Excel recognize the text, YEAR, as a variable and will
appropriately insert the value there, as :

"Now, we're in 2006."

Is this possible to do in Excel?

Thanks,

Devin


--
DevinC
------------------------------------------------------------------------
DevinC's Profile: http://www.excelforum.com/member.php...o&userid=22739
View this thread: http://www.excelforum.com/showthread...hreadid=505186



Norman Jones

Variable in string
 
Hi Devin,

Range("A1").Value = "Now, we're in " & Year & "."


should read:

Range("A1").Value = "Now, we're in " & sYear & "."

---
Regards,
Norman



Ken Johnson

Variable in string
 
Hi Devin,
without using a variable the following in any cell will update for
whatever year it happens to be:

="Now, we're in " & YEAR(NOW()) & "."

Ken Johnson


DevinC

Variable in string
 

Thanks guys!


--
DevinC
------------------------------------------------------------------------
DevinC's Profile: http://www.excelforum.com/member.php...o&userid=22739
View this thread: http://www.excelforum.com/showthread...hreadid=505186



All times are GMT +1. The time now is 05:36 AM.

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