PC Review


Reply
Thread Tools Rate Thread

Delete some letters

 
 
darkblue
Guest
Posts: n/a
 
      26th Jun 2011
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
 
Reply With Quote
 
 
 
 
Don Guillett
Guest
Posts: n/a
 
      29th Jun 2011
On Jun 26, 2:45*pm, darkblue <ahmet...@gmail.com> 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

 
Reply With Quote
 
Don Guillett
Guest
Posts: n/a
 
      30th Jun 2011
On Jun 26, 2:45*pm, darkblue <ahmet...@gmail.com> 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
 
Reply With Quote
 
darkblue
Guest
Posts: n/a
 
      1st Jul 2011
Thank you Don, works charmingly.

Kind regards
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
delete saved letters =?Utf-8?B?TGFubnksIGJyYW5kIG5ldyB0byB0aGUgY29tcHV0 Microsoft Word New Users 3 12th Sep 2009 02:05 PM
delete first 4 letters in a cell Wanna Learn Microsoft Excel Misc 3 2nd Jan 2009 07:00 PM
How do I delete letters on right of cursor Spider1 Microsoft Word New Users 1 11th May 2008 02:55 PM
Delete all letters? jeremy via OfficeKB.com Microsoft Excel Misc 3 7th Jun 2005 12:02 AM
How do I delete the last two letters of a cell Steve Microsoft Excel Worksheet Functions 6 19th May 2004 08:33 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 07:17 PM.