+ Reply to Thread
Results 1 to 3 of 3

Remove the space between the variable and the constant part of a file name

  1. #1
    Registered User
    Join Date
    05-08-2012
    Location
    Manchester
    MS-Off Ver
    Excel 2010
    Posts
    36

    Question Remove the space between the variable and the constant part of a file name

    Hi everyone,

    I have 800+ files the problem is that the file name ends in 80 different combination so I need to try all of those for each file.
    eg: one of the 800 is "109 st no 103 av" the file could be called:
    "109 st no 103 av nb1_cleaned.xls" or
    "109 st no 103 av nb 1_cleaned.xls" or
    "109 st no 103 av nb 1._cleaned.xls" or
    "109 st no 103 av sb1_cleaned.xls"
    .
    .
    .
    .etc

    I worte a code to try all those combinations, the issue lies a space the code adds before _cleaned, any ideas how to remove it?.

    So the name should be
    "109 st no 103 av nb1_cleaned.xls"
    but my code is letting it be
    109 st no 103 av nb1 _cleaned.xls

    where the variable Ord is the "1" after nb.

    Please find the code below:

    Please Login or Register  to view this content.
    Any help is appreciated!!
    Last edited by SirRyanGiggs; 06-07-2014 at 11:12 PM.

  2. #2
    Registered User
    Join Date
    05-08-2012
    Location
    Manchester
    MS-Off Ver
    Excel 2010
    Posts
    36

    Re: Trying to open files with variable names

    I think I figured out the issue, its a space the code adds before _cleaned, but I still dont know how to remove it?.

    So the name should be
    "109 st no 103 av nb1_cleaned.xls"
    but my code is letting it be
    109 st no 103 av nb1 _cleaned.xls

    where the variable Ord is the "1" after nb

  3. #3
    Forum Contributor pareshj's Avatar
    Join Date
    05-20-2014
    Location
    MUMBAI
    MS-Off Ver
    2007 & 2010
    Posts
    447

    Re: Trying to open files with variable names

    Hi

    Add trim function to filename, Check the below code,

    Please Login or Register  to view this content.

    Hope this will solve your problem.


    Regards,
    Paresh J
    Click on "* Add Reputation" as a way to say thanks

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. VBA to open multiple files with different, unknown file names
    By jreed52 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 02-28-2014, 12:03 PM
  2. [SOLVED] Macro to open multiple files with changing names
    By KeithMale in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 05-27-2013, 07:28 PM
  3. Open text files with changing names
    By BJ5352 in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 12-02-2010, 06:54 PM
  4. Populate a Dropdown with names of open workbooks, when slected store as variable
    By andersonca in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 02-18-2010, 12:11 PM
  5. Rename files with variable names
    By Robert_L_Ross in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 06-20-2006, 01:55 PM

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