• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 90
  • Last Modified:

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

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
Ray
Asked:
Ray
  • 2
  • 2
1 Solution
 
NorieCommented:
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
 
RayData AnalystAuthor Commented:
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
 
RayData AnalystAuthor Commented:
Oh, I should note that the "yyy" part gave me a 'funky' number for year so I used "yyyy".
0
 
NorieCommented:
No problem, sorry about the missing y, thing my keyboard needs a clean.:)
0

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now