Saving input figures.
I forgot the most important part, it is too late at night, sorry!
Option Explicit
Private Sub Workbook_BeforeSave(ByVal SaveAsUI As _
Boolean, Cancel As Boolean)
Dim i As Long
Dim MyRange As Range
Dim MyNameIs As String
'Procedure here to harvest the data into a range
'For example, suppose there are
'Data in Rows 1 through 10
On Error GoTo err_Handler
For i = 1 To 10
If MyRange Is Nothing Then
Set MyRange = Cells(i, 1).EntireRow
Else
Set MyRange = Union(MyRange, Cells(i, 1).EntireRow)
End If
Next i
'Create the workbook to actually save
With Workbooks.Add
MyRange.Copy Destination:=Range("A1")
MyNameIs = InputBox("What shall we name this workbook " & _
"it cannot be: " & vbCr & _
ThisWorkbook.Path & "\" & _
ThisWorkbook.Name, _
"Saving to a new File", ThisWorkbook.Path & "\NewName.Xls")
.SaveAs (MyNameIs)
End With
Exit_Me:
Cancel = True '''''' very important!!!
Exit Sub
err_Handler:
MsgBox Err.Description
Resume Exit_Me
End Sub
"William Benson" wrote in message
...
I think what you may be looking for Glenn is this -- it is just a model of
what you can do in the BeforeSave event in the ThisWorkbook code Module:
Private Sub Workbook_BeforeSave(ByVal SaveAsUI As _
Boolean, Cancel As Boolean)
Dim i As Long
Dim MyRange As Range
Dim MyNameIs As String
'Procedure here to harvest the data into a range
'For example, suppose there are
'Data in Rows 1 through 10
On Error GoTo err_Handler
For i = 1 To 10
If MyRange Is Nothing Then
Set MyRange = Cells(i, 1).EntireRow
Else
Set MyRange = Union(MyRange, Cells(i, 1).EntireRow)
End If
Next i
'Create the workbook to actually save
With Workbooks.Add
MyRange.Copy Destination:=Range("A1")
MyNameIs = InputBox("What shall we name this workbook " & _
"it cannot be: " & vbCr & _
ThisWorkbook.Path & "\" & _
ThisWorkbook.Name, _
"Saving to a new File", ThisWorkbook.Path & "\NewName.Xls")
.SaveAs (MyNameIs)
End With
Exit_Me:
Exit Sub
err_Handler:
MsgBox Err.Description
Resume Exit_Me
End Sub
"glenn" wrote in message
...
I have built this program. Is there a way u I can save the imputed
information and not the entire templete used. Also when i want to click
on
this saved info will it load it into the templete?
THANKS GLENN
|