Solved

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

Posted on 2015-01-26
4
85 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 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 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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

How to quickly and accurately populate Word documents with Excel data, charts and images (including Automated Bookmark generation) David Miller (dlmille) Synopsis In this article you’ll learn how to use ExcelToWord! to copy data,charts, shapes …
Do you use a spreadsheet like Microsoft's Excel?  Have you ever wanted to link out to a non excel file on your computer or network drive?  This is the way I found to do it!
The viewer will learn how to use a discrete random variable to simulate the return on an investment over a period of years, create a Monte Carlo simulation using the discrete random variable, and create a graph to represent the possible returns over…
This Micro Tutorial demonstrates in Microsoft Excel how to consolidate your marketing data by creating an interactive charts using form controls. This creates cool drop-downs for viewers of your chart to choose from.

724 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