Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 30
Default how to auto change a file name?

How could i make a workbook change its file name once data has been entered
in a curtain cell?

example:

file name format would be, Week No.# (Date on sunday of that week).xls

all the data is stored in a list like this:

wk_num = B3:B55 = 1:53
week/start = D3:D55 = 29/03/2004:28/03/2005
week/end = E3:E55 dates = 04/04/2004:03/04/2005

if the current week is 7, user inputs 7 in cell A1 workbook now renames to,
Week No.7 (16.05.2004).xls

hope that makes sense, many thanks for any help,

Steve



  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default how to auto change a file name?

Steve,

Here is one way

Private Sub Worksheet_Change(ByVal Target As Range)
Dim sFile As String
Dim iPos As Long

On Error GoTo ws_exit:
Application.EnableEvents = False
If Not Intersect(Target, Me.Range("C1")) Is Nothing Then
With Target
iPos = Application.Match(.Value, Me.Range("B3:B55"), 0)
sFile = "Week No." & .Value & " (" & _
Format(Application.Index(Me.Range("D3:D55"), iPos),
"dd.mm.yyyy") & _
")."
ThisWorkbook.SaveAs Filename:=sFile
End With
End If

ws_exit:
Application.EnableEvents = True
End Sub


It is worksheet event code, so right-click on the sheet tab, select View
Code from the menu, and past it in.

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"Steven" wrote in message news:u8Knc.123$Kw6.2@newsfe1-win...
How could i make a workbook change its file name once data has been

entered
in a curtain cell?

example:

file name format would be, Week No.# (Date on sunday of that week).xls

all the data is stored in a list like this:

wk_num = B3:B55 = 1:53
week/start = D3:D55 = 29/03/2004:28/03/2005
week/end = E3:E55 dates = 04/04/2004:03/04/2005

if the current week is 7, user inputs 7 in cell A1 workbook now renames

to,
Week No.7 (16.05.2004).xls

hope that makes sense, many thanks for any help,

Steve





  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 30
Default how to auto change a file name?

Thanks Bob, very much appreciated

Steve

"Bob Phillips" wrote in message
...
Steve,

Here is one way

Private Sub Worksheet_Change(ByVal Target As Range)
Dim sFile As String
Dim iPos As Long

On Error GoTo ws_exit:
Application.EnableEvents = False
If Not Intersect(Target, Me.Range("C1")) Is Nothing Then
With Target
iPos = Application.Match(.Value, Me.Range("B3:B55"), 0)
sFile = "Week No." & .Value & " (" & _
Format(Application.Index(Me.Range("D3:D55"), iPos),
"dd.mm.yyyy") & _
")."
ThisWorkbook.SaveAs Filename:=sFile
End With
End If

ws_exit:
Application.EnableEvents = True
End Sub


It is worksheet event code, so right-click on the sheet tab, select View
Code from the menu, and past it in.

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"Steven" wrote in message

news:u8Knc.123$Kw6.2@newsfe1-win...
How could i make a workbook change its file name once data has been

entered
in a curtain cell?

example:

file name format would be, Week No.# (Date on sunday of that week).xls

all the data is stored in a list like this:

wk_num = B3:B55 = 1:53
week/start = D3:D55 = 29/03/2004:28/03/2005
week/end = E3:E55 dates = 04/04/2004:03/04/2005

if the current week is 7, user inputs 7 in cell A1 workbook now renames

to,
Week No.7 (16.05.2004).xls

hope that makes sense, many thanks for any help,

Steve







  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 30
Default how to auto change a file name?

Bob, the code did not work at first, made some changes and now it does!

Private Sub Worksheet_Change(ByVal Target As Range)
Dim sFile As String
Dim iPos As Long

On Error GoTo ws_exit:
Application.EnableEvents = False
If Not Intersect(Target, Me.Range("A1")) Is Nothing Then
With Target
iPos = Application.Match(.Value, Me.Range("B3:B55"), 0)
sFile = "Week No." & .Value & " (" & _
Format(Application.Index(Me.Range("E3:E55"), iPos),
"dd.mm.yyyy") & _
")."
ThisWorkbook.SaveAs Filename:=sFile
End With
End If

ws_exit:
Application.EnableEvents = True
End Sub

Many thanks,
Steve
"Bob Phillips" wrote in message
...
Steve,

Here is one way

Private Sub Worksheet_Change(ByVal Target As Range)
Dim sFile As String
Dim iPos As Long

On Error GoTo ws_exit:
Application.EnableEvents = False
If Not Intersect(Target, Me.Range("C1")) Is Nothing Then
With Target
iPos = Application.Match(.Value, Me.Range("B3:B55"), 0)
sFile = "Week No." & .Value & " (" & _
Format(Application.Index(Me.Range("D3:D55"), iPos),
"dd.mm.yyyy") & _
")."
ThisWorkbook.SaveAs Filename:=sFile
End With
End If

ws_exit:
Application.EnableEvents = True
End Sub


It is worksheet event code, so right-click on the sheet tab, select View
Code from the menu, and past it in.

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"Steven" wrote in message

news:u8Knc.123$Kw6.2@newsfe1-win...
How could i make a workbook change its file name once data has been

entered
in a curtain cell?

example:

file name format would be, Week No.# (Date on sunday of that week).xls

all the data is stored in a list like this:

wk_num = B3:B55 = 1:53
week/start = D3:D55 = 29/03/2004:28/03/2005
week/end = E3:E55 dates = 04/04/2004:03/04/2005

if the current week is 7, user inputs 7 in cell A1 workbook now renames

to,
Week No.7 (16.05.2004).xls

hope that makes sense, many thanks for any help,

Steve







  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default how to auto change a file name?

Sorry, didn't pay enough attention to where you defined the data.

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"Steven" wrote in message
...
Bob, the code did not work at first, made some changes and now it does!

Private Sub Worksheet_Change(ByVal Target As Range)
Dim sFile As String
Dim iPos As Long

On Error GoTo ws_exit:
Application.EnableEvents = False
If Not Intersect(Target, Me.Range("A1")) Is Nothing Then
With Target
iPos = Application.Match(.Value, Me.Range("B3:B55"), 0)
sFile = "Week No." & .Value & " (" & _
Format(Application.Index(Me.Range("E3:E55"), iPos),
"dd.mm.yyyy") & _
")."
ThisWorkbook.SaveAs Filename:=sFile
End With
End If

ws_exit:
Application.EnableEvents = True
End Sub

Many thanks,
Steve
"Bob Phillips" wrote in message
...
Steve,

Here is one way

Private Sub Worksheet_Change(ByVal Target As Range)
Dim sFile As String
Dim iPos As Long

On Error GoTo ws_exit:
Application.EnableEvents = False
If Not Intersect(Target, Me.Range("C1")) Is Nothing Then
With Target
iPos = Application.Match(.Value, Me.Range("B3:B55"), 0)
sFile = "Week No." & .Value & " (" & _
Format(Application.Index(Me.Range("D3:D55"), iPos),
"dd.mm.yyyy") & _
")."
ThisWorkbook.SaveAs Filename:=sFile
End With
End If

ws_exit:
Application.EnableEvents = True
End Sub


It is worksheet event code, so right-click on the sheet tab, select View
Code from the menu, and past it in.

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"Steven" wrote in message

news:u8Knc.123$Kw6.2@newsfe1-win...
How could i make a workbook change its file name once data has been

entered
in a curtain cell?

example:

file name format would be, Week No.# (Date on sunday of that week).xls

all the data is stored in a list like this:

wk_num = B3:B55 = 1:53
week/start = D3:D55 = 29/03/2004:28/03/2005
week/end = E3:E55 dates = 04/04/2004:03/04/2005

if the current week is 7, user inputs 7 in cell A1 workbook now

renames
to,
Week No.7 (16.05.2004).xls

hope that makes sense, many thanks for any help,

Steve











  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 30
Default how to auto change a file name?

Bob how can i specify the location for the file to be saved ? currently its
saving to My Documents.

Many thanks,
Steve

"Bob Phillips" wrote in message
...
Sorry, didn't pay enough attention to where you defined the data.

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"Steven" wrote in message
...
Bob, the code did not work at first, made some changes and now it does!

Private Sub Worksheet_Change(ByVal Target As Range)
Dim sFile As String
Dim iPos As Long

On Error GoTo ws_exit:
Application.EnableEvents = False
If Not Intersect(Target, Me.Range("A1")) Is Nothing Then
With Target
iPos = Application.Match(.Value, Me.Range("B3:B55"), 0)
sFile = "Week No." & .Value & " (" & _
Format(Application.Index(Me.Range("E3:E55"), iPos),
"dd.mm.yyyy") & _
")."
ThisWorkbook.SaveAs Filename:=sFile
End With
End If

ws_exit:
Application.EnableEvents = True
End Sub

Many thanks,
Steve
"Bob Phillips" wrote in message
...
Steve,

Here is one way

Private Sub Worksheet_Change(ByVal Target As Range)
Dim sFile As String
Dim iPos As Long

On Error GoTo ws_exit:
Application.EnableEvents = False
If Not Intersect(Target, Me.Range("C1")) Is Nothing Then
With Target
iPos = Application.Match(.Value, Me.Range("B3:B55"), 0)
sFile = "Week No." & .Value & " (" & _
Format(Application.Index(Me.Range("D3:D55"),

iPos),
"dd.mm.yyyy") & _
")."
ThisWorkbook.SaveAs Filename:=sFile
End With
End If

ws_exit:
Application.EnableEvents = True
End Sub


It is worksheet event code, so right-click on the sheet tab, select

View
Code from the menu, and past it in.

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"Steven" wrote in message

news:u8Knc.123$Kw6.2@newsfe1-win...
How could i make a workbook change its file name once data has been
entered
in a curtain cell?

example:

file name format would be, Week No.# (Date on sunday of that

week).xls

all the data is stored in a list like this:

wk_num = B3:B55 = 1:53
week/start = D3:D55 = 29/03/2004:28/03/2005
week/end = E3:E55 dates = 04/04/2004:03/04/2005

if the current week is 7, user inputs 7 in cell A1 workbook now

renames
to,
Week No.7 (16.05.2004).xls

hope that makes sense, many thanks for any help,

Steve











  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default how to auto change a file name?

Steve,

You could try a couple of ways, and see which suits best.

First, use the GetSaveFileName method, which allows you to browse and input
a filename

Dim sFile

sFile = Application.GetSaveAsFilename( _
fileFilter:="Microsoft Excel Workbooks (*.xls), *.xls")
If sFile < False Then
ActiveWorkbook.SaveAs Filename:=sFile
End If

or you can simply change the directory

ChDrive "C:\Steven\Test"
ChDir "C:\Steven\Test"

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"Steven" wrote in message news:r5Nnc.22$5N2.19@newsfe6-win...
Bob how can i specify the location for the file to be saved ? currently

its
saving to My Documents.

Many thanks,
Steve

"Bob Phillips" wrote in message
...
Sorry, didn't pay enough attention to where you defined the data.

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"Steven" wrote in message
...
Bob, the code did not work at first, made some changes and now it

does!

Private Sub Worksheet_Change(ByVal Target As Range)
Dim sFile As String
Dim iPos As Long

On Error GoTo ws_exit:
Application.EnableEvents = False
If Not Intersect(Target, Me.Range("A1")) Is Nothing Then
With Target
iPos = Application.Match(.Value, Me.Range("B3:B55"), 0)
sFile = "Week No." & .Value & " (" & _
Format(Application.Index(Me.Range("E3:E55"),

iPos),
"dd.mm.yyyy") & _
")."
ThisWorkbook.SaveAs Filename:=sFile
End With
End If

ws_exit:
Application.EnableEvents = True
End Sub

Many thanks,
Steve
"Bob Phillips" wrote in message
...
Steve,

Here is one way

Private Sub Worksheet_Change(ByVal Target As Range)
Dim sFile As String
Dim iPos As Long

On Error GoTo ws_exit:
Application.EnableEvents = False
If Not Intersect(Target, Me.Range("C1")) Is Nothing Then
With Target
iPos = Application.Match(.Value, Me.Range("B3:B55"), 0)
sFile = "Week No." & .Value & " (" & _
Format(Application.Index(Me.Range("D3:D55"),

iPos),
"dd.mm.yyyy") & _
")."
ThisWorkbook.SaveAs Filename:=sFile
End With
End If

ws_exit:
Application.EnableEvents = True
End Sub


It is worksheet event code, so right-click on the sheet tab, select

View
Code from the menu, and past it in.

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"Steven" wrote in message
news:u8Knc.123$Kw6.2@newsfe1-win...
How could i make a workbook change its file name once data has

been
entered
in a curtain cell?

example:

file name format would be, Week No.# (Date on sunday of that

week).xls

all the data is stored in a list like this:

wk_num = B3:B55 = 1:53
week/start = D3:D55 = 29/03/2004:28/03/2005
week/end = E3:E55 dates = 04/04/2004:03/04/2005

if the current week is 7, user inputs 7 in cell A1 workbook now

renames
to,
Week No.7 (16.05.2004).xls

hope that makes sense, many thanks for any help,

Steve













  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 30
Default how to auto change a file name?

Where in the code would i insert ChDrive "C:\Steven\Test" ChDir
"C:\Steven\Test" ? or the GetSaveFileName method ?

Many thanks Bob,

Steve


"Bob Phillips" wrote in message
...
Steve,

You could try a couple of ways, and see which suits best.

First, use the GetSaveFileName method, which allows you to browse and

input
a filename

Dim sFile

sFile = Application.GetSaveAsFilename( _
fileFilter:="Microsoft Excel Workbooks (*.xls), *.xls")
If sFile < False Then
ActiveWorkbook.SaveAs Filename:=sFile
End If

or you can simply change the directory

ChDrive "C:\Steven\Test"
ChDir "C:\Steven\Test"

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"Steven" wrote in message

news:r5Nnc.22$5N2.19@newsfe6-win...
Bob how can i specify the location for the file to be saved ? currently

its
saving to My Documents.

Many thanks,
Steve

"Bob Phillips" wrote in message
...
Sorry, didn't pay enough attention to where you defined the data.

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"Steven" wrote in message
...
Bob, the code did not work at first, made some changes and now it

does!

Private Sub Worksheet_Change(ByVal Target As Range)
Dim sFile As String
Dim iPos As Long

On Error GoTo ws_exit:
Application.EnableEvents = False
If Not Intersect(Target, Me.Range("A1")) Is Nothing Then
With Target
iPos = Application.Match(.Value, Me.Range("B3:B55"), 0)
sFile = "Week No." & .Value & " (" & _
Format(Application.Index(Me.Range("E3:E55"),

iPos),
"dd.mm.yyyy") & _
")."
ThisWorkbook.SaveAs Filename:=sFile
End With
End If

ws_exit:
Application.EnableEvents = True
End Sub

Many thanks,
Steve
"Bob Phillips" wrote in message
...
Steve,

Here is one way

Private Sub Worksheet_Change(ByVal Target As Range)
Dim sFile As String
Dim iPos As Long

On Error GoTo ws_exit:
Application.EnableEvents = False
If Not Intersect(Target, Me.Range("C1")) Is Nothing Then
With Target
iPos = Application.Match(.Value, Me.Range("B3:B55"),

0)
sFile = "Week No." & .Value & " (" & _
Format(Application.Index(Me.Range("D3:D55"),

iPos),
"dd.mm.yyyy") & _
")."
ThisWorkbook.SaveAs Filename:=sFile
End With
End If

ws_exit:
Application.EnableEvents = True
End Sub


It is worksheet event code, so right-click on the sheet tab,

select
View
Code from the menu, and past it in.

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"Steven" wrote in message
news:u8Knc.123$Kw6.2@newsfe1-win...
How could i make a workbook change its file name once data has

been
entered
in a curtain cell?

example:

file name format would be, Week No.# (Date on sunday of that

week).xls

all the data is stored in a list like this:

wk_num = B3:B55 = 1:53
week/start = D3:D55 = 29/03/2004:28/03/2005
week/end = E3:E55 dates = 04/04/2004:03/04/2005

if the current week is 7, user inputs 7 in cell A1 workbook now
renames
to,
Week No.7 (16.05.2004).xls

hope that makes sense, many thanks for any help,

Steve















  #9   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default how to auto change a file name?

The first method would replace the line

ThisWorkbook.SaveAs Filename:=sFile

The second would be immediately before it.

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"Steven" wrote in message
...
Where in the code would i insert ChDrive "C:\Steven\Test" ChDir
"C:\Steven\Test" ? or the GetSaveFileName method ?

Many thanks Bob,

Steve


"Bob Phillips" wrote in message
...
Steve,

You could try a couple of ways, and see which suits best.

First, use the GetSaveFileName method, which allows you to browse and

input
a filename

Dim sFile

sFile = Application.GetSaveAsFilename( _
fileFilter:="Microsoft Excel Workbooks (*.xls), *.xls")
If sFile < False Then
ActiveWorkbook.SaveAs Filename:=sFile
End If

or you can simply change the directory

ChDrive "C:\Steven\Test"
ChDir "C:\Steven\Test"

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"Steven" wrote in message

news:r5Nnc.22$5N2.19@newsfe6-win...
Bob how can i specify the location for the file to be saved ?

currently
its
saving to My Documents.

Many thanks,
Steve

"Bob Phillips" wrote in message
...
Sorry, didn't pay enough attention to where you defined the data.

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"Steven" wrote in message
...
Bob, the code did not work at first, made some changes and now it

does!

Private Sub Worksheet_Change(ByVal Target As Range)
Dim sFile As String
Dim iPos As Long

On Error GoTo ws_exit:
Application.EnableEvents = False
If Not Intersect(Target, Me.Range("A1")) Is Nothing Then
With Target
iPos = Application.Match(.Value, Me.Range("B3:B55"),

0)
sFile = "Week No." & .Value & " (" & _
Format(Application.Index(Me.Range("E3:E55"),

iPos),
"dd.mm.yyyy") & _
")."
ThisWorkbook.SaveAs Filename:=sFile
End With
End If

ws_exit:
Application.EnableEvents = True
End Sub

Many thanks,
Steve
"Bob Phillips" wrote in

message
...
Steve,

Here is one way

Private Sub Worksheet_Change(ByVal Target As Range)
Dim sFile As String
Dim iPos As Long

On Error GoTo ws_exit:
Application.EnableEvents = False
If Not Intersect(Target, Me.Range("C1")) Is Nothing Then
With Target
iPos = Application.Match(.Value, Me.Range("B3:B55"),

0)
sFile = "Week No." & .Value & " (" & _
Format(Application.Index(Me.Range("D3:D55"),
iPos),
"dd.mm.yyyy") & _
")."
ThisWorkbook.SaveAs Filename:=sFile
End With
End If

ws_exit:
Application.EnableEvents = True
End Sub


It is worksheet event code, so right-click on the sheet tab,

select
View
Code from the menu, and past it in.

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"Steven" wrote in message
news:u8Knc.123$Kw6.2@newsfe1-win...
How could i make a workbook change its file name once data has

been
entered
in a curtain cell?

example:

file name format would be, Week No.# (Date on sunday of that
week).xls

all the data is stored in a list like this:

wk_num = B3:B55 = 1:53
week/start = D3:D55 = 29/03/2004:28/03/2005
week/end = E3:E55 dates = 04/04/2004:03/04/2005

if the current week is 7, user inputs 7 in cell A1 workbook

now
renames
to,
Week No.7 (16.05.2004).xls

hope that makes sense, many thanks for any help,

Steve

















  #10   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 30
Default how to auto change a file name?

Thanks Bob for the continued support

Steve

"Bob Phillips" wrote in message
...
The first method would replace the line

ThisWorkbook.SaveAs Filename:=sFile

The second would be immediately before it.

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"Steven" wrote in message
...
Where in the code would i insert ChDrive "C:\Steven\Test" ChDir
"C:\Steven\Test" ? or the GetSaveFileName method ?

Many thanks Bob,

Steve


"Bob Phillips" wrote in message
...
Steve,

You could try a couple of ways, and see which suits best.

First, use the GetSaveFileName method, which allows you to browse and

input
a filename

Dim sFile

sFile = Application.GetSaveAsFilename( _
fileFilter:="Microsoft Excel Workbooks (*.xls), *.xls")
If sFile < False Then
ActiveWorkbook.SaveAs Filename:=sFile
End If

or you can simply change the directory

ChDrive "C:\Steven\Test"
ChDir "C:\Steven\Test"

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"Steven" wrote in message

news:r5Nnc.22$5N2.19@newsfe6-win...
Bob how can i specify the location for the file to be saved ?

currently
its
saving to My Documents.

Many thanks,
Steve

"Bob Phillips" wrote in message
...
Sorry, didn't pay enough attention to where you defined the data.

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"Steven" wrote in message
...
Bob, the code did not work at first, made some changes and now

it
does!

Private Sub Worksheet_Change(ByVal Target As Range)
Dim sFile As String
Dim iPos As Long

On Error GoTo ws_exit:
Application.EnableEvents = False
If Not Intersect(Target, Me.Range("A1")) Is Nothing Then
With Target
iPos = Application.Match(.Value, Me.Range("B3:B55"),

0)
sFile = "Week No." & .Value & " (" & _
Format(Application.Index(Me.Range("E3:E55"),
iPos),
"dd.mm.yyyy") & _
")."
ThisWorkbook.SaveAs Filename:=sFile
End With
End If

ws_exit:
Application.EnableEvents = True
End Sub

Many thanks,
Steve
"Bob Phillips" wrote in

message
...
Steve,

Here is one way

Private Sub Worksheet_Change(ByVal Target As Range)
Dim sFile As String
Dim iPos As Long

On Error GoTo ws_exit:
Application.EnableEvents = False
If Not Intersect(Target, Me.Range("C1")) Is Nothing Then
With Target
iPos = Application.Match(.Value,

Me.Range("B3:B55"),
0)
sFile = "Week No." & .Value & " (" & _

Format(Application.Index(Me.Range("D3:D55"),
iPos),
"dd.mm.yyyy") & _
")."
ThisWorkbook.SaveAs Filename:=sFile
End With
End If

ws_exit:
Application.EnableEvents = True
End Sub


It is worksheet event code, so right-click on the sheet tab,

select
View
Code from the menu, and past it in.

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"Steven" wrote in message
news:u8Knc.123$Kw6.2@newsfe1-win...
How could i make a workbook change its file name once data

has
been
entered
in a curtain cell?

example:

file name format would be, Week No.# (Date on sunday of that
week).xls

all the data is stored in a list like this:

wk_num = B3:B55 = 1:53
week/start = D3:D55 = 29/03/2004:28/03/2005
week/end = E3:E55 dates = 04/04/2004:03/04/2005

if the current week is 7, user inputs 7 in cell A1 workbook

now
renames
to,
Week No.7 (16.05.2004).xls

hope that makes sense, many thanks for any help,

Steve





















  #11   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default how to auto change a file name?

It's a pleasure. I try to keep a handle on the thread, just in case<g

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"Steven" wrote in message
...
Thanks Bob for the continued support

Steve

"Bob Phillips" wrote in message
...
The first method would replace the line

ThisWorkbook.SaveAs Filename:=sFile

The second would be immediately before it.

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"Steven" wrote in message
...
Where in the code would i insert ChDrive "C:\Steven\Test" ChDir
"C:\Steven\Test" ? or the GetSaveFileName method ?

Many thanks Bob,

Steve


"Bob Phillips" wrote in message
...
Steve,

You could try a couple of ways, and see which suits best.

First, use the GetSaveFileName method, which allows you to browse

and
input
a filename

Dim sFile

sFile = Application.GetSaveAsFilename( _
fileFilter:="Microsoft Excel Workbooks (*.xls), *.xls")
If sFile < False Then
ActiveWorkbook.SaveAs Filename:=sFile
End If

or you can simply change the directory

ChDrive "C:\Steven\Test"
ChDir "C:\Steven\Test"

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"Steven" wrote in message
news:r5Nnc.22$5N2.19@newsfe6-win...
Bob how can i specify the location for the file to be saved ?

currently
its
saving to My Documents.

Many thanks,
Steve

"Bob Phillips" wrote in

message
...
Sorry, didn't pay enough attention to where you defined the

data.

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"Steven" wrote in message
...
Bob, the code did not work at first, made some changes and now

it
does!

Private Sub Worksheet_Change(ByVal Target As Range)
Dim sFile As String
Dim iPos As Long

On Error GoTo ws_exit:
Application.EnableEvents = False
If Not Intersect(Target, Me.Range("A1")) Is Nothing Then
With Target
iPos = Application.Match(.Value,

Me.Range("B3:B55"),
0)
sFile = "Week No." & .Value & " (" & _

Format(Application.Index(Me.Range("E3:E55"),
iPos),
"dd.mm.yyyy") & _
")."
ThisWorkbook.SaveAs Filename:=sFile
End With
End If

ws_exit:
Application.EnableEvents = True
End Sub

Many thanks,
Steve
"Bob Phillips" wrote in

message
...
Steve,

Here is one way

Private Sub Worksheet_Change(ByVal Target As Range)
Dim sFile As String
Dim iPos As Long

On Error GoTo ws_exit:
Application.EnableEvents = False
If Not Intersect(Target, Me.Range("C1")) Is Nothing Then
With Target
iPos = Application.Match(.Value,

Me.Range("B3:B55"),
0)
sFile = "Week No." & .Value & " (" & _

Format(Application.Index(Me.Range("D3:D55"),
iPos),
"dd.mm.yyyy") & _
")."
ThisWorkbook.SaveAs Filename:=sFile
End With
End If

ws_exit:
Application.EnableEvents = True
End Sub


It is worksheet event code, so right-click on the sheet tab,
select
View
Code from the menu, and past it in.

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"Steven" wrote in message
news:u8Knc.123$Kw6.2@newsfe1-win...
How could i make a workbook change its file name once data

has
been
entered
in a curtain cell?

example:

file name format would be, Week No.# (Date on sunday of

that
week).xls

all the data is stored in a list like this:

wk_num = B3:B55 = 1:53
week/start = D3:D55 = 29/03/2004:28/03/2005
week/end = E3:E55 dates = 04/04/2004:03/04/2005

if the current week is 7, user inputs 7 in cell A1

workbook
now
renames
to,
Week No.7 (16.05.2004).xls

hope that makes sense, many thanks for any help,

Steve





















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
auto change sharon Excel Worksheet Functions 4 February 26th 07 06:13 PM
Can I auto save to a separate file?(not the file I am working in) Jim Lynch Setting up and Configuration of Excel 1 August 14th 06 05:20 PM
2 users open same file and both can edit/change the file RANDY Excel Discussion (Misc queries) 1 January 24th 06 04:06 PM
auto save excel file every 10 minutes to its original file name MEG Excel Discussion (Misc queries) 3 September 8th 05 07:12 PM
How do I change file/open/"files of type" to default to "all file. How do I changefiles of type default Excel Discussion (Misc queries) 1 April 19th 05 10:45 PM


All times are GMT +1. The time now is 10:03 AM.

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

About Us

"It's about Microsoft Excel"