Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 65
Default save file as different name until cell is blank

I have a worksheet that needs to be saved in anywhere from 1 to 6 different
locations depending on the contents of cells AH1 through AH6 (this is where
the filenames are stored). I want the macro to save to all filenames in
this range, but I don't want a runtime error when one of the cells is blank,
for example if there are only 4 filenames instead of 6. Presently, my code
is

Sub Save_to_root()
Dim fname
With ActiveWorkbook
fname = .Worksheets("Daily").Range("AH1").Value & ".xls"
..SaveAs fname
End With
End Sub

Can someone help with the adjustment? Thanks, Pam
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default save file as different name until cell is blank

Hi Pam

Try this
Note: I use SaveCopyAs

Sub test()
Dim fname As String

For I = 1 To 6
With ActiveWorkbook
If .Worksheets("Daily").Range("AH" & I).Value < "" Then
fname = .Worksheets("Daily").Range("AH" & I).Value & ".xls"
.SaveCopyAs fname
End If
End With

Next I
End Sub


--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm




"Pam M" wrote in message ...
I have a worksheet that needs to be saved in anywhere from 1 to 6 different
locations depending on the contents of cells AH1 through AH6 (this is where
the filenames are stored). I want the macro to save to all filenames in
this range, but I don't want a runtime error when one of the cells is blank,
for example if there are only 4 filenames instead of 6. Presently, my code
is

Sub Save_to_root()
Dim fname
With ActiveWorkbook
fname = .Worksheets("Daily").Range("AH1").Value & ".xls"
.SaveAs fname
End With
End Sub

Can someone help with the adjustment? Thanks, Pam

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,049
Default save file as different name until cell is blank

newsreader probs - sorry for double post

"Patrick Molloy" wrote in message
...
Sub Save_to_root()
Dim fname
dim cell as range
With ActiveWorkbook
for each cell in .Worksheets("Daily").Range("AH1:AH6").Cells
if cell.value<"" then
fname = cell.Value & ".xls"
.SaveAs fname
end if
next
End With
End Sub


"Pam M" wrote:

I have a worksheet that needs to be saved in anywhere from 1 to 6
different
locations depending on the contents of cells AH1 through AH6 (this is
where
the filenames are stored). I want the macro to save to all filenames in
this range, but I don't want a runtime error when one of the cells is
blank,
for example if there are only 4 filenames instead of 6. Presently, my
code
is

Sub Save_to_root()
Dim fname
With ActiveWorkbook
fname = .Worksheets("Daily").Range("AH1").Value & ".xls"
.SaveAs fname
End With
End Sub

Can someone help with the adjustment? Thanks, Pam


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default save file as different name until cell is blank

Hi Patrick

Better two then nothing <g


--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm




"Patrick Molloy" wrote in message ...
newsreader probs - sorry for double post

"Patrick Molloy" wrote in message
...
Sub Save_to_root()
Dim fname
dim cell as range
With ActiveWorkbook
for each cell in .Worksheets("Daily").Range("AH1:AH6").Cells
if cell.value<"" then
fname = cell.Value & ".xls"
.SaveAs fname
end if
next
End With
End Sub


"Pam M" wrote:

I have a worksheet that needs to be saved in anywhere from 1 to 6
different
locations depending on the contents of cells AH1 through AH6 (this is
where
the filenames are stored). I want the macro to save to all filenames in
this range, but I don't want a runtime error when one of the cells is
blank,
for example if there are only 4 filenames instead of 6. Presently, my
code
is

Sub Save_to_root()
Dim fname
With ActiveWorkbook
fname = .Worksheets("Daily").Range("AH1").Value & ".xls"
.SaveAs fname
End With
End Sub

Can someone help with the adjustment? Thanks, Pam


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 65
Default save file as different name until cell is blank

These both worked well. I chose Rons because it allowed the file to stay
where it was while just depositing a copy which set me up for the next macro
save that I needed to do. Thanks so much to you both! Pam

"Ron de Bruin" wrote:

Hi Pam

Try this
Note: I use SaveCopyAs

Sub test()
Dim fname As String

For I = 1 To 6
With ActiveWorkbook
If .Worksheets("Daily").Range("AH" & I).Value < "" Then
fname = .Worksheets("Daily").Range("AH" & I).Value & ".xls"
.SaveCopyAs fname
End If
End With

Next I
End Sub


--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm




"Pam M" wrote in message ...
I have a worksheet that needs to be saved in anywhere from 1 to 6 different
locations depending on the contents of cells AH1 through AH6 (this is where
the filenames are stored). I want the macro to save to all filenames in
this range, but I don't want a runtime error when one of the cells is blank,
for example if there are only 4 filenames instead of 6. Presently, my code
is

Sub Save_to_root()
Dim fname
With ActiveWorkbook
fname = .Worksheets("Daily").Range("AH1").Value & ".xls"
.SaveAs fname
End With
End Sub

Can someone help with the adjustment? Thanks, Pam


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
Trying to delete blank rows after file save pm Excel Discussion (Misc queries) 2 April 15th 10 11:58 PM
save file as different name until cell is blank Patrick Molloy[_2_] Excel Programming 0 June 18th 09 04:14 PM
save file as different name until cell is blank Patrick Molloy Excel Programming 0 June 18th 09 04:08 PM
SAVE OR SAVE-AS with a file name derived from a cell on the spreadsheet... KLZA Excel Programming 0 July 31st 07 03:52 PM
save an excel file in fixed length records whose fields are blank ascii save Excel Discussion (Misc queries) 1 October 13th 05 06:01 PM


All times are GMT +1. The time now is 02:16 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"