Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
ST ST is offline
external usenet poster
 
Posts: 14
Default Get a specific cell value/text inserted in a macro

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default Get a specific cell value/text inserted in a macro

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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Can I send an inserted shape behind the cell text? stevieB Excel Discussion (Misc queries) 1 November 19th 08 06:53 PM
Macro - delete entire row which contain a specific text Dileep Chandran Excel Worksheet Functions 1 December 6th 06 01:08 PM
macro to insert row after specific text Luke Excel Discussion (Misc queries) 2 September 19th 05 04:06 PM
Text not all displaying in a cell, what is max that can be inserted? Althea Excel Worksheet Functions 4 May 9th 05 02:41 AM
Macro to copy text to a specific cell reference shanman_lmtd Excel Programming 3 July 23rd 04 03:32 PM


All times are GMT +1. The time now is 10:59 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"