Kate
01-17-2007, 06:10 AM
Hello,
I am trying to modify the code below, taken from MDMcKillop's response to someone elses question.
Here the need is to accept the values of 2 cells as the Name of the file I want to SaveAs.
‘The line combinations (s1Name, s2Name & s3Name) below did not work. Is this even possible? : pray2:
Const Fld = "C:\Documents and Settings\kjusoro\Desktop\FiscalK\"
Sub SaveNamedCopy()
Dim NewFileName As String
Dim StartWkBk As Workbook
Dim sName As Variant
Call ToggleStuff(False)
On Error GoTo Exits
Set StartWkBk = ActiveWorkbook
sName = ActiveSheet.Range("G1").Value
‘----------------------------------------------------------------------------
's1Name = Range("A1") & " " & Range("G1").Value
's2Name = Sheets("Sheet1").Range("A1") & " " & Range("G1").Value
's3Name = Sheets("Sheet1").Range("A1" & " " & "G1").Value
‘----------------------------------------------------------------------------
'NewFileName = InputBox("Enter a new file name to save: ")
NewFileName = sName
With StartWkBk
.Sheets(Array("Sheet1", "Sheet3")).Copy
ActiveSheet.Select
ActiveWorkbook.SaveAs Filename:=Fld & NewFileName & ".xls"
End With
ActiveWorkbook.Close SaveChanges:=False
Exits:
ToggleStuff True
End Sub
Public Sub ToggleStuff(x As Boolean)
Application.ScreenUpdating = x
Application.DisplayAlerts = x
Application.EnableEvents = x
End Sub
Thank you,
kate
I am trying to modify the code below, taken from MDMcKillop's response to someone elses question.
Here the need is to accept the values of 2 cells as the Name of the file I want to SaveAs.
‘The line combinations (s1Name, s2Name & s3Name) below did not work. Is this even possible? : pray2:
Const Fld = "C:\Documents and Settings\kjusoro\Desktop\FiscalK\"
Sub SaveNamedCopy()
Dim NewFileName As String
Dim StartWkBk As Workbook
Dim sName As Variant
Call ToggleStuff(False)
On Error GoTo Exits
Set StartWkBk = ActiveWorkbook
sName = ActiveSheet.Range("G1").Value
‘----------------------------------------------------------------------------
's1Name = Range("A1") & " " & Range("G1").Value
's2Name = Sheets("Sheet1").Range("A1") & " " & Range("G1").Value
's3Name = Sheets("Sheet1").Range("A1" & " " & "G1").Value
‘----------------------------------------------------------------------------
'NewFileName = InputBox("Enter a new file name to save: ")
NewFileName = sName
With StartWkBk
.Sheets(Array("Sheet1", "Sheet3")).Copy
ActiveSheet.Select
ActiveWorkbook.SaveAs Filename:=Fld & NewFileName & ".xls"
End With
ActiveWorkbook.Close SaveChanges:=False
Exits:
ToggleStuff True
End Sub
Public Sub ToggleStuff(x As Boolean)
Application.ScreenUpdating = x
Application.DisplayAlerts = x
Application.EnableEvents = x
End Sub
Thank you,
kate