Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I am a new programmer in VBA and have many questions. This one first:
I want to make a macro, which saves a workarea as the value in a specific cell. ex. A1 contains the value 25, then I want the macro to save the workarea as 25.xls, without asking for the filename. I hope the question is understandable. |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
Dim s as String s = Thisworkbook.Path If right(s,1) < "\" then s = s & "\" End if On Error goto ErrHandler Application.DisplayAlerts = False Application.enableEvents = False thisworkbook.Saveas s & Thisworkbook _ .Worksheets("Data").Range("A1").Value & _ ".xls" ErrHandler: Cancel = True if err.Number < 0 then msgbox "Problems saving workbook" End if Application.EnableEvents = True Application.DisplayAlerts = True End Sub go into the VBE and select your project in the project explorer. On the ThisWorkbook Entry, right click and select view code. In the dropdowns at the top of the resulting module, select workbook from the left and beforesave from the right. Put in code like the above. -- Regards, Tom Ogilvy "ST" wrote: I am a new programmer in VBA and have many questions. This one first: I want to make a macro, which saves a workarea as the value in a specific cell. ex. A1 contains the value 25, then I want the macro to save the workarea as 25.xls, without asking for the filename. I hope the question is understandable. |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Can I send an inserted shape behind the cell text? | Excel Discussion (Misc queries) | |||
Macro - delete entire row which contain a specific text | Excel Worksheet Functions | |||
macro to insert row after specific text | Excel Discussion (Misc queries) | |||
Text not all displaying in a cell, what is max that can be inserted? | Excel Worksheet Functions | |||
Macro to copy text to a specific cell reference | Excel Programming |