Solved

vb macro strFileName based in field in excel sheet

Posted on 2013-12-26
3
521 Views
Last Modified: 2013-12-26
folks

how can i make my output file name exported from excel (using a macro) be named after a field in the excel sheet itself?

i.e. the value from B1 from sheet 1


strDefFolder = Trim(InputBox(" Enter path to save file", "File Location", ""))
system = field B1

strFileName = system & Day

All help will do
0
Comment
Question by:rutgermons
[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
3 Comments
 
LVL 70

Expert Comment

by:Qlemo
ID: 39739893
You can use e.g. System = [B1].Value or System = Range("B1").Value if you are in Sheet1, or System = [Sheet1!B1].Value if in another sheet. Even better, name your field, and use that name instead of B1.
0
 
LVL 3

Accepted Solution

by:
CvD earned 500 total points
ID: 39739915
suppose field B1 contains "myfile.txt" and field B1 resides in worksheet sheet1, the solution could be something in the line of:

dim temp as variant
temp = Split(worksheets("sheet1").range("B1").value,".")
strFileName = temp(0) & Date & "." & temp(1)

resulting in strFilename containing "myfile26-12-2013.txt"
(atleast it would be in Dutch date notation :-) )
0
 

Author Closing Comment

by:rutgermons
ID: 39740540
Thanks CvD, your comment was the most complete solution and worked for me!

cheers
0

Featured Post

[Webinar] Learn How Hackers Steal Your Credentials

Do You Know How Hackers Steal Your Credentials? Join us and Skyport Systems to learn how hackers steal your credentials and why Active Directory must be secure to stop them. Thursday, July 13, 2017 10:00 A.M. PDT

Question has a verified solution.

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

A little background as to how I came to I design this code: Around 5 years ago I designed an add-in that formatted Excel files to a corporate standard, applying different cell colours and font type depending on whether the cells contained inputs,…
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 create a normally distributed random variable in Excel, use a normal distribution to simulate the return on an investment over a period of years, Create a Monte Carlo simulation using a normal random variable, and calcul…
This Micro Tutorial will demonstrate the scrolling table in Microsoft Excel using the INDEX function.

705 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