?
Solved

vb macro strFileName based in field in excel sheet

Posted on 2013-12-26
3
Medium Priority
?
534 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
3 Comments
 
LVL 71

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 2000 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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

This code takes an Excel list of URL’s and adds a header titled “URL List”. It then searches through all URL’s in column “A”, looking for duplicates. When a duplicate is found, it is moved to the top of the list. The duplicate URL’s are then highlig…
This article descibes how to create a connection between Excel and SAP and how to move data from Excel to SAP or the other way around.
The viewer will learn how to create two correlated normally distributed random variables in Excel, use a normal distribution to simulate the return on different levels of investment in each of the two funds over a period of ten years, and, create a …
This Micro Tutorial demonstrates how to create Excel charts: column, area, line, bar, and scatter charts. Formatting tips are provided as well.

840 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