Do not use on any
shared computer
May 10, 2008 03:30pm pdt
03.27.2008 at 12:09PM PDT, ID: 23275243 | Points: 500
[x]
Attachment Details
Inserting a Date in filename in a Macro
Tags: VBA Excel
I have recorded a Macro in MS-Excel, where in the macro has to pick up files from a shared drive, one of the file will be saved with same name on daily basis, where as the other one will be saved with filename+current date.

Ex: sharedrive08\data08\combined08\march-2008\file0325

Currently I have a calendar setup and am able to get a selected date to a particular cell.Say I have date in Cell "B13", how can i connect that to a filename in the Macro. All  I have to change is "0325" part of the filename.

I have to connect three different Dates to three different files in the Macro, is it possible to have three different dates in three different Cells say "B13","B16", "B20" to be connected to three different filenames with three different paths?

Scenario Example : As soon as I have 0328 in Cell "B13" then the Macro should pick up file named "Filename0328" to perform necessary functionality.

I wish to change the dates where ever they are in the Macro.txt file attached.

Any help with written code examples would be of great help. Thanks in Advance.
Attachments:
 
This file contains recorded Macro.
 
Start your free trial to view this solution
Question Stats
Zone: Software
Question Asked By: sval1411
Question Asked On: 03.27.2008
Participating Experts: 2
Points: 500
Views: 0
Translate:
Loading Advertisement...
03.27.2008 at 12:16PM PDT, ID: 21224820

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
03.27.2008 at 12:29PM PDT, ID: 21224936

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
03.27.2008 at 12:41PM PDT, ID: 21225016

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
03.27.2008 at 12:43PM PDT, ID: 21225037

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
03.27.2008 at 02:36PM PDT, ID: 21225995

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
03.27.2008 at 02:40PM PDT, ID: 21226032

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
03.27.2008 at 02:46PM PDT, ID: 21226092

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
 
Loading Advertisement...
Microsoft
  • Internet Protocols
  • Applications
  • Development
  • OS
  • Hardware
  • Windows Security
Apple
  • Operating Systems
  • Hardware
  • Programming
  • Networking
  • Software
Internet
  • Search Engines
  • File Sharing
  • WebTrends / Stats
  • Spy / Ad Blockers
  • Web Browsers
  • New Net Users
  • Web Development
  • Chat / IM
  • Anti Spam
  • Web Servers
  • Anti-Virus
  • Email Clients
Gamers
  • Tips
  • Online / MMORPG
  • Puzzle
  • Emulators
  • Action / Adventure
  • Role Playing
  • Consoles
  • Game Programming
  • Strategy
  • Sports
  • Misc
  • Computer Games
Digital Living
  • Hardware
  • New Net Users
  • New Users
  • Software
  • Digital Music
  • Gaming World
  • Home Security
  • Apple
  • Networking Hardware
Virus & Spyware
  • Vulnerabilities
  • IDS
  • Encryption
  • Anti-Virus
  • Operating Systems Security
  • Software Firewalls
  • WebApplications
  • Cell Phones
  • Operating Systems
  • Internet
  • Hardware Firewalls
Hardware
  • Handhelds / PDAs
  • Displays / Monitors
  • Components
  • Networking Hardware
  • Peripherals
  • Laptops/Notebooks
  • Storage
  • Servers
  • Desktops
  • New Users
  • Misc
  • Apple
Software
  • System Utilities
  • Industry Specific
  • Network Management
  • Photos / Graphics
  • Page Layout
  • VMWare
  • Misc
  • Web Development
  • OS
  • CYGWIN
  • Voice Recognition
  • Message Queue
  • Quality Assurance
  • Security
  • Firewalls
  • MultiMedia Applications
  • Development
  • Database
  • Office / Productivity
  • Business Management
  • OS/2 Apps
  • Server Software
  • Internet / Email
ITPro
  • OS
  • Storage
  • Encryption
  • Operating Systems Security
  • Apple Hardware
  • Laptops & Notebooks
  • Servers
  • Networking Hardware
  • Peripherals
  • Devices
  • Displays / Monitors
  • WebTrends / Stats
  • Search Engines
  • Firewalls
  • WebApplications
  • IDS
  • Vulnerabilities
  • Email Clients
  • File Sharing
  • Spy / Ad Blockers
  • Web Browsers
  • Web Servers
  • Networking
  • Anti-Virus
  • Chat / IM
  • Anti Spam
Developer
  • Web Servers
  • Web Browsers
  • Game Programming
  • Dev Tools
  • Industry Specific
  • Office / Productivity
  • Database
  • CYGWIN
  • Web Development
  • Search Engines
  • File Sharing
  • WebTrends / Stats
  • Programming
  • Content Management
  • Application Servers
  • Protocols
Storage
  • Removable Backup Media
  • Storage Technology
  • Servers
  • Grid
  • Remote Access
  • Backup / Restore
  • Misc
  • Hard Drives
OS
  • Miscellaneous
  • Security
  • Development
  • Linux
  • VMWare
  • MainFrame OS
  • Unix
  • Apple
  • OS / 2
  • AS / 400
  • BeOS
  • Microsoft
  • VMS / OpenVMS
Database
  • Oracle
  • Miscellaneous
  • MySQL
  • Software
  • Sybase
  • Contact Management
  • PostgreSQL
  • Data Manipulation
  • Clarion
  • InterSystems Cache
  • Siebel
  • MUMPS
  • OLAP
  • SQLBase
  • SAS
  • GIS & GPS
  • 4GL
  • Berkeley DB
  • DB2
  • Informix
  • Interbase / Firebird
  • FoxPro
  • Reporting
  • LDAP
  • Filemaker Pro
  • MS SQL Server
  • dBase
  • MS Access
Security
  • Misc
  • Web Browsers
  • Software Firewalls
  • Operating Systems Security
  • File Sharing
  • Spy / Ad Blockers
  • Vulnerabilities
  • WebApplications
  • IDS
  • Anti-Virus
  • Encryption
  • Anti Spam
  • Email Clients
  • VPN
  • Chat / IM
Programming
  • Editors IDEs
  • Installation
  • Handhelds / PDAs
  • Multimedia Programming
  • System / Kernel
  • Algorithms
  • Game
  • Signal Processing
  • Project Management
  • Open Source
  • Database
  • Misc
  • Languages
  • Processor Platforms
  • Theory
Web Development
  • Scripting
  • Blogs
  • Web Servers
  • Software
  • Search Engines
  • Web Graphics
  • Images
  • Internet Marketing
  • Images and Photos
  • Components
  • Document Imaging
  • Web Languages/Standards
  • Illustration
  • WebApplications
  • Fonts
  • WebTrends / Stats
  • Authoring
  • Digital Camera Software
  • Miscellaneous
Networking
  • Protocols
  • Apple Networking
  • Network Management
  • Message Queue
  • Application Servers
  • Content Management
  • File Servers
  • Email Servers
  • Misc
  • Java Editors & IDEs
  • Wireless
  • Networking Hardware
  • Backup / Restore
  • System Utilities
  • ISPs & Hosting
  • Web Servers
  • Storage Technology
  • Removable Backup Media
  • Servers
  • Broadband
  • Grid
  • OS / 2
  • Novell Netware
  • Unix Networking
  • Windows Networking
  • Security
  • Telecommunications
  • Operating Systems
  • Linux Networking
Other
  • Community Advisor
  • Lounge
  • Community Support
  • New Net Users
  • Philosophy / Religion
  • Math / Science
  • Miscellaneous
  • URLs
  • Expert Lounge
  • Politics
  • Puzzles / Riddles
Community Support
  • Suggestions
  • New to EE
  • New Topics
  • Community Advisor
  • CleanUp
  • Announcements
  • General
  • Feedback
  • Input
  • EE Bugs
 
03.27.2008 at 12:16PM PDT, ID: 21224820
try using dynamic strings eg:
1:
2:
    ActiveWorkbook.SaveAs Filename:= _
        "\\Andshare06\data06$\ACCOUNT06\ASDSHARE06\GPS TA Group\ARAP" & ActiveSheet.Range("B13") & ".Macro.xls"
Open in New Window
 
03.27.2008 at 12:29PM PDT, ID: 21224936
May be, let me check coding it.

Thanks for a quick response.
1:
2:
3:
4:
 ActiveWorkbook.SaveAs Filename:= _
        "\\Andshare06\data06$\ACCOUNT06\ASDSHARE06\GPS TA Group\ARAP" & ActiveSheet.Range("B13") & ".Macro.xls"
 
The first file is not an .xls sheet, would it still work ?
Open in New Window
 
03.27.2008 at 12:41PM PDT, ID: 21225016
this should work fine

eg. cell B13 = 0805

text file is called gl_accts_ar0805.txt

the below script will find it.
1:
"\\Andshare06\data06$\ACCOUNT06\ASDSHARE06\GPS TA Group\gl_accts_ar" & ActiveSheet.Range("B13") & ".txt"
Open in New Window
 
03.27.2008 at 12:43PM PDT, ID: 21225037
you can even use if to change folders eg.

where cell B1 = ACCOUNT06
1:
"\\Andshare06\data06$\" & ActiveSheet.Range("B1") & "\ASDSHARE06\GPS TA Group\gl_accts_ar" & ActiveSheet.Range("B13") & ".txt"
Open in New Window
 
03.27.2008 at 02:36PM PDT, ID: 21225995
With Application.FileSearch
    FolderToSearch = "C:\Macro" '
    End With
   
 
   
    ActiveWorkbook.SaveAs FolderToSearch & "/" & ".Macro" & "_" & Format$(Date, "mm_dd_yyyy"), FileFormat:=xlNormal
 
03.27.2008 at 02:40PM PDT, ID: 21226032
Although it is pulling the Dates, it is giving errors on "Origin:= " and "Startrow:="

The date it is pulling is not in the format I have formtted the Cell to be. I formatted the cell to be in mmdd format, where as the file extension is coming up as mm/dd/yyyy .

Anyways thanks for your help.
 
03.27.2008 at 02:46PM PDT, ID: 21226092
this should fix the date problem:

Format(ActiveSheet.Range("B13"), "mmdd")
 
 
20080206-EE-VQP-25 / EE_QW_2_20070628