Solved

vb macro strFileName based in field in excel sheet

Posted on 2013-12-26
3
512 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 69

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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Deploying a Microsoft Access application in a Citrix environment is not difficult but takes a few steps. However, Citrix system people are often of little help, as they typically know next to nothing about Access. The script provided here will take …
Excel can be a tricky bit of software to get your head around. Whilst you’ll be able to eventually get to grips with the basic understanding of how to get by, there are a few Excel tips that not everybody will even know about let alone know how to d…
This Micro Tutorial will demonstrate on a Mac how to change the sort order for chart legend values and decrpyt the intimidating chart menu.
This Micro Tutorial will demonstrate the scrolling table in Microsoft Excel using the INDEX function.

733 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