View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
Bob Phillips[_6_] Bob Phillips[_6_] is offline
external usenet poster
 
Posts: 11,272
Default macro to save as

You need to put it in a sub:-)

Sub SaveMyFile()
sFilename = Format(Worksheets("Sheet1").Range("A1").Value, "yyyy-mm-dd")
ans = MsgBox ("Save file as " & sFilename)
if ans = vbOK Then
Activeworkbook.SaveAs Filename:= sFilename
End If
End Sub

--

HTH

RP
(remove nothere from the email address if mailing direct)


"Mo" wrote in message
...
Bob,

I got an error message - "Complie Error, Invalid outside procedure"
it highlite the ("A1")

"Bob Phillips" wrote:

sFilename = Format(Worksheets("Sheet1").Range("A1").Value,

"yyyy-mm-dd")
ans = MsgBox ("Save file as " & sFilename)
if ans = vbOK Then
Activeworkbook.SaveAs Filename:= sFilename
End If

should do it

--

HTH

RP
(remove nothere from the email address if mailing direct)


"Mo" wrote in message
...
I need to create a macro & assign it to a button. the macro needs to

save
the current file based on a date that is entered in a cell. also the

macro
needs to prompt the user to verify the filename(date) and then save it

and
return to the current worksheet.

thanks

Mo