Solved

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

Posted on 2015-01-26
4
78 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
No problem, sorry about the missing y, thing my keyboard needs a clean.:)
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Dealing with unintended Excel Active-X resizing quirks (VBA code simulates "self correction") David Miller (dlmille) Intro Not everyone is a fan of Active-X controls in spreadsheets (as opposed to the UserForm approach, the older Form controls …
Introduction This Article is a follow-up to my Mappit! Addin Article (http://www.experts-exchange.com/A_2613.html), it was inspired by an email posting I made to EUSPRIG (http://www.eusprig.org/index.htm), I will briefly cover: 1) An overvie…
This Micro Tutorial demonstrate the bugs in Microsoft Excel for Mac with Pivot 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…

744 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

13 Experts available now in Live!

Get 1:1 Help Now