Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35
Default Delete some letters

Hi
Currently i am doing it manually but i was wondering if this can be
done by vba.
I have several documents to be read in a folder. When i read them i
put "-R" at the end of doc name. But before moving some of them to the
archive (another folder) i have to delete this "-R" bits. So folder
"archive" must have no docs ending with "-R". How can i do that ? Any
idea ?
Thanks in advance
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,522
Default Delete some letters

On Jun 26, 2:45*pm, darkblue wrote:
Hi
Currently i am doing it manually but i was wondering if this can be
done by vba.
I have several documents to be read in a folder. When i read them i
put "-R" at the end of doc name. But before moving some of them to the
archive (another folder) i have to delete this "-R" bits. So folder
"archive" must have no docs ending with "-R". How can i do that ? Any
idea ?
Thanks in advance


Should do it. You can move withIN the same macro

Sub renamefiles()
Dim fn As String
Dim mPath As String
mPath = "C:\aa\" 'location of files
ChDir mPath
fn = Dir("*.xls") 'or your ext
Do While fn < ""
If Right(fn, 6) = "-R.xls" Then
'MsgBox sFil
Dim OldName, NewName
OldName = fn
NewName = Left(fn, Len(fn) - 6) & ".xls"
Name OldName As NewName ' Rename file.
End If
fn = Dir
Loop
End Sub

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,522
Default Delete some letters

On Jun 26, 2:45*pm, darkblue wrote:
Hi
Currently i am doing it manually but i was wondering if this can be
done by vba.
I have several documents to be read in a folder. When i read them i
put "-R" at the end of doc name. But before moving some of them to the
archive (another folder) i have to delete this "-R" bits. So folder
"archive" must have no docs ending with "-R". How can i do that ? Any
idea ?
Thanks in advance

Resending

Sub renamefiles()
Dim fn As String
Dim mPath As String
mPath = "C:\aa\" 'location of files
ChDir mPath
fn = Dir("*.xls") 'or your ext
Do While fn < ""
If Right(fn, 6) = "-R.xls" Then
'MsgBox sFil
Dim OldName, NewName
OldName = fn
NewName = Left(fn, Len(fn) - 6) & ".xls"
Name OldName As NewName ' Rename file.
End If
fn = Dir
Loop
End Sub
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35
Default Delete some letters

Thank you Don, works charmingly.

Kind regards
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
delete first 4 letters in a cell Wanna Learn Excel Discussion (Misc queries) 4 April 3rd 23 01:26 PM
i delete a program that converts number into letters whattahec Excel Discussion (Misc queries) 1 February 13th 09 09:39 AM
How do change a column of data in capitol letters to small letters Barb P. Excel Discussion (Misc queries) 6 November 15th 06 06:17 PM
How to delete in batch the same color format letters in a cell yang xin Excel Worksheet Functions 1 February 5th 06 04:42 AM
Delete all letters? jeremy via OfficeKB.com Excel Discussion (Misc queries) 3 June 7th 05 12:02 AM


All times are GMT +1. The time now is 12:46 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"