Solved

Build a string in Excel VBA that would be the same as this formula

Posted on 2015-01-26
4
79 Views
Last Modified: 2015-01-26
I have this formula in a cell within my workbook.
=CONCATENATE(E4, " ", TEXT(A1,"mmmm")," ",TEXT(A1,"yyyy")," MyFile")
Instead of depending on that cell to exist I just want to set a string to equal the result that would be in that cell via VBA
Assuming my string is created and is named "FileName" how do I get filename = the value of that 'formula'?
0
Comment
Question by:Ray
  • 2
  • 2
4 Comments
 
LVL 33

Accepted Solution

by:
Norie earned 500 total points
ID: 40570964
You don't say which cell the formula is in or sheet it's on but let's assume it's in F4 on Sheet1.

This code will put the result of the formula in FileName.
FileName = Sheets("Sheet1").Range("F4").Value

Open in new window


If you don't want to use the formula you could use this.
FileName = Sheets("Sheet1").Range("E4").Value & " " & Format(Sheets("Sheet1").Range("A1").Value, "mmmm yyy ") & " MyFIle"

Open in new window

0
 
LVL 10

Author Comment

by:Ray
ID: 40570981
Thanks Norie!  NOT using the formula was indeed the point.  I was able to plug all the right things into your syntax and get just what I needed.  :-)
0
 
LVL 10

Author Comment

by:Ray
ID: 40570983
Oh, I should note that the "yyy" part gave me a 'funky' number for year so I used "yyyy".
0
 
LVL 33

Expert Comment

by:Norie
ID: 40571008
No problem, sorry about the missing y, thing my keyboard needs a clean.:)
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Workbook link problems after copying tabs to a new workbook? David Miller (dlmille) Intro Have you either copied sheets to a new workbook, and after having saved and opened that workbook, you find that there are links back to the original sou…
Some code to ensure data integrity when using macros within Excel. Also included code that helps secure your data within an Excel workbook.
This Micro Tutorial will demonstrate in Microsoft Excel how to add style and sexy appeal to horizontal bar charts.
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

920 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now