+ Reply to Thread
Results 1 to 3 of 3

Using 'Name ..... As .....' with a wildcard

  1. #1
    Registered User
    Join Date
    11-07-2011
    Location
    Melbourne, Australia
    MS-Off Ver
    Excel 2010
    Posts
    25

    Using 'Name ..... As .....' with a wildcard

    Trying to write part of a macro to rename a file held in a specific directory. Each day the directory will hold a different file with a different file name however the first several characters will always be the same.

    The directory is C:\Report Files\Daily File\ and the file always starts with same characters - 'PCDAILY' (file name is normally something like 'PCDAILY03082012' or 'PCDAILY26072012')

    My aim is to rename the file so it's always called 'PCDAILY' (getting rid of all the superfluous numbers) so I can use that name reference throughout the rest of the macro. I am trying to use a wildcard in conjunction with the 'Name' statement to alter the name but cannot get it to work.

    Please Login or Register  to view this content.
    Would greatly appreciate any suggestions.

    Thanks,

    Daniel.
    Last edited by Iwasiw35; 08-05-2012 at 09:44 PM.

  2. #2
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,482

    Re: Using 'Name ..... As .....' with a wildcard

    If the folder only contains 1 file then use the DIR function to get the correct name of that file.

    Please Login or Register  to view this content.
    Cheers
    Andy
    www.andypope.info

  3. #3
    Registered User
    Join Date
    11-07-2011
    Location
    Melbourne, Australia
    MS-Off Ver
    Excel 2010
    Posts
    25

    Re: Using 'Name ..... As .....' with a wildcard

    I had to slightly tinker with your suggested code (wouldn't work with "If Len...." line sitting above "NewName = ...." but once I switched them around it works perfectly. Thanks heaps for your help Andy. I should be able to use this for one or two other reports as well.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1