Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi all, I have excel files with names (see below) in folder "C:\My
Documents\Forms". PERMANENT TRANSFER FORM (BT) - 552360.xlsm PERMANENT TRANSFER FORM (BT) - 512360.xlsm PERMANENT TRANSFER FORM (BT) - 556360 - PG 1.xlsm PERMANENT TRANSFER FORM (BT) - 556360 - PG 2.xlsm PERMANENT FAQS FORM (BT) - 546660 - 546661.xlsm PERMANENT REQ FORM (BT) - 598774 - 598775.xlsm I want macro on a button which should shorten the name something like (see below) of all the files in the folder. 552360.xlsm 512360.xlsm 556360 - PG 1.xlsm 556360 - PG 2.xlsm 546660 - 546661.xlsm 598774 - 598775.xlsm Please can any friend can help. |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() Filename = Dir("C:\My Documents\Forms\*.xls" Do While Filename < "" NewName = Right(Filename, Len(Filename) - Instr(Filename, "-") - 1) Name Filename, NewName Filename = Dir Loop -- __________________________________ HTH Bob "K" wrote in message ... Hi all, I have excel files with names (see below) in folder "C:\My Documents\Forms". PERMANENT TRANSFER FORM (BT) - 552360.xlsm PERMANENT TRANSFER FORM (BT) - 512360.xlsm PERMANENT TRANSFER FORM (BT) - 556360 - PG 1.xlsm PERMANENT TRANSFER FORM (BT) - 556360 - PG 2.xlsm PERMANENT FAQS FORM (BT) - 546660 - 546661.xlsm PERMANENT REQ FORM (BT) - 598774 - 598775.xlsm I want macro on a button which should shorten the name something like (see below) of all the files in the folder. 552360.xlsm 512360.xlsm 556360 - PG 1.xlsm 556360 - PG 2.xlsm 546660 - 546661.xlsm 598774 - 598775.xlsm Please can any friend can help. |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
On Feb 3, 9:44*am, "Bob Phillips" wrote:
*Filename = Dir("C:\My Documents\Forms\*.xls" *Do While Filename < "" * NewName = Right(Filename, Len(Filename) - Instr(Filename, "-") - 1) * Name Filename, NewName * Filename = Dir *Loop -- __________________________________ HTH Bob "K" wrote in message ... Hi all, *I have excel files with names (see below) in folder "C:\My Documents\Forms". PERMANENT TRANSFER FORM (BT) - 552360.xlsm PERMANENT TRANSFER FORM (BT) - 512360.xlsm PERMANENT TRANSFER FORM (BT) - 556360 - PG 1.xlsm PERMANENT TRANSFER FORM (BT) - 556360 - PG 2.xlsm PERMANENT FAQS FORM (BT) - 546660 - 546661.xlsm PERMANENT REQ FORM (BT) - 598774 - 598775.xlsm I want macro on a button which should shorten the name something like (see below) of all the files in the folder. 552360.xlsm 512360.xlsm 556360 - PG 1.xlsm 556360 - PG 2.xlsm 546660 - 546661.xlsm 598774 - 598775.xlsm Please can any friend can help.- Hide quoted text - - Show quoted text - thanks for replying Bob. i am getting error on line Name Filename, NewName. please can you tell me what i am doing wrong |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Untested, uncompiled:
Filename = Dir("C:\My Documents\Forms\*.xls") Do While Filename < "" NewName = Right(Filename, Len(Filename) - InStr(Filename, "-") - 1) Name Filename As NewName Filename = Dir Loop K wrote: On Feb 3, 9:44 am, "Bob Phillips" wrote: Filename = Dir("C:\My Documents\Forms\*.xls" Do While Filename < "" NewName = Right(Filename, Len(Filename) - Instr(Filename, "-") - 1) Name Filename, NewName Filename = Dir Loop -- __________________________________ HTH Bob "K" wrote in message ... Hi all, I have excel files with names (see below) in folder "C:\My Documents\Forms". PERMANENT TRANSFER FORM (BT) - 552360.xlsm PERMANENT TRANSFER FORM (BT) - 512360.xlsm PERMANENT TRANSFER FORM (BT) - 556360 - PG 1.xlsm PERMANENT TRANSFER FORM (BT) - 556360 - PG 2.xlsm PERMANENT FAQS FORM (BT) - 546660 - 546661.xlsm PERMANENT REQ FORM (BT) - 598774 - 598775.xlsm I want macro on a button which should shorten the name something like (see below) of all the files in the folder. 552360.xlsm 512360.xlsm 556360 - PG 1.xlsm 556360 - PG 2.xlsm 546660 - 546661.xlsm 598774 - 598775.xlsm Please can any friend can help.- Hide quoted text - - Show quoted text - thanks for replying Bob. i am getting error on line Name Filename, NewName. please can you tell me what i am doing wrong -- Dave Peterson |
#5
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Sorry, my Excel was down last night.
Try this Filename = Dir("C:\My Documents\Forms\*.xls") Do While Filename < "" NewName = Right(Filename, Len(Filename) - InStr(Filename, "-") - 1) Name Filename As NewName Filename = Dir Loop -- __________________________________ HTH Bob "K" wrote in message ... On Feb 3, 9:44 am, "Bob Phillips" wrote: Filename = Dir("C:\My Documents\Forms\*.xls" Do While Filename < "" NewName = Right(Filename, Len(Filename) - Instr(Filename, "-") - 1) Name Filename, NewName Filename = Dir Loop -- __________________________________ HTH Bob "K" wrote in message ... Hi all, I have excel files with names (see below) in folder "C:\My Documents\Forms". PERMANENT TRANSFER FORM (BT) - 552360.xlsm PERMANENT TRANSFER FORM (BT) - 512360.xlsm PERMANENT TRANSFER FORM (BT) - 556360 - PG 1.xlsm PERMANENT TRANSFER FORM (BT) - 556360 - PG 2.xlsm PERMANENT FAQS FORM (BT) - 546660 - 546661.xlsm PERMANENT REQ FORM (BT) - 598774 - 598775.xlsm I want macro on a button which should shorten the name something like (see below) of all the files in the folder. 552360.xlsm 512360.xlsm 556360 - PG 1.xlsm 556360 - PG 2.xlsm 546660 - 546661.xlsm 598774 - 598775.xlsm Please can any friend can help.- Hide quoted text - - Show quoted text - thanks for replying Bob. i am getting error on line Name Filename, NewName. please can you tell me what i am doing wrong |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Macro to change file properties | Excel Programming | |||
Macro speed change when closing file | Excel Programming | |||
macro to change tab name to file name | Excel Programming | |||
Macro to change sign on text file imported to Excel | Excel Programming | |||
Change Code in Macro to specify file/folder to look in. | Excel Programming |