B
bigjim
I want to save three worksheets in my main workbook to a new workbook to be
named from variables in "Main.xls". For Example: I have 3 worksheets in
"main.xls" called "ticket", "Job Report", and "W-15". I need to create a new
workbook named from the contents of cells A4 and K10 in worksheet "Calc" in
workbook "Main.xls" and then save copies of "ticket", "job report" and "w-15"
in this new workbook. So, if cell a4 had "AS011" in it and K10 had "Liberty"
in it, the new file would be named "As011Liberty.xls" and contain three
sheets named "ticket", "Job Report", and "W-15". I am working in Excell 2003
and this is what I have so far, but I can't seem to get it to work:
Dim strappend As String
Dim strpath As String
Dim str3 As String
Dim str4 As String
strappend = ActiveSheet.Range("a4")
strpath = "c:\field tickets\"
str3 = ActiveSheet.Range("k10")
fsavename = strpath & strappend & str3 & ".xls"
If Dir(fsavename) <> "" Then
fsavename = strpath & strappend & str3 & "a.xls"
End If
If Dir(fsavename) <> "" Then
fsavename = strpath & strappend & str3 & "b.xls"
End If
If Dir(fsavename) <> "" Then
fsavename = strpath & strappend & str3 & "c.xls"
End If
ActiveWorkbook.Sheets("Ticket").SaveAs fsavename
ActiveWorkbook.Close False
ActiveWorkbook.Sheets("Job Report").Select
Sheets("Job Report").Copy before:=Workbooks("fsname").Sheets("Ticket")
ActiveWorkbook.Sheets("W-15").Select
Sheets("W-15").Copy before:=Workbooks("fsname").Sheets("Job Report")
I would appreciate any help I could get.
Thanks,
Jim
named from variables in "Main.xls". For Example: I have 3 worksheets in
"main.xls" called "ticket", "Job Report", and "W-15". I need to create a new
workbook named from the contents of cells A4 and K10 in worksheet "Calc" in
workbook "Main.xls" and then save copies of "ticket", "job report" and "w-15"
in this new workbook. So, if cell a4 had "AS011" in it and K10 had "Liberty"
in it, the new file would be named "As011Liberty.xls" and contain three
sheets named "ticket", "Job Report", and "W-15". I am working in Excell 2003
and this is what I have so far, but I can't seem to get it to work:
Dim strappend As String
Dim strpath As String
Dim str3 As String
Dim str4 As String
strappend = ActiveSheet.Range("a4")
strpath = "c:\field tickets\"
str3 = ActiveSheet.Range("k10")
fsavename = strpath & strappend & str3 & ".xls"
If Dir(fsavename) <> "" Then
fsavename = strpath & strappend & str3 & "a.xls"
End If
If Dir(fsavename) <> "" Then
fsavename = strpath & strappend & str3 & "b.xls"
End If
If Dir(fsavename) <> "" Then
fsavename = strpath & strappend & str3 & "c.xls"
End If
ActiveWorkbook.Sheets("Ticket").SaveAs fsavename
ActiveWorkbook.Close False
ActiveWorkbook.Sheets("Job Report").Select
Sheets("Job Report").Copy before:=Workbooks("fsname").Sheets("Ticket")
ActiveWorkbook.Sheets("W-15").Select
Sheets("W-15").Copy before:=Workbooks("fsname").Sheets("Job Report")
I would appreciate any help I could get.
Thanks,
Jim