?
Solved

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

Posted on 2015-01-26
4
Medium Priority
?
86 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 
LVL 34

Accepted Solution

by:
Norie earned 2000 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 11

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 11

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 34

Expert Comment

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

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

When you see single cell contains number and text, and you have to get any date out of it seems like cracking our heads.
This article describes a serious pitfall that can happen when deleting shapes using VBA.
This Micro Tutorial will demonstrate how to use longer labels with horizontal bar charts instead of the vertical column chart.
This Micro Tutorial will demonstrate how to use a scrolling table in Microsoft Excel using the INDEX function.

764 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