Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 258
Default Macro to save Excel file

I have a macro that saves an Excel file with specific name and path (see
below).
However, sometimes I forget the fill out the information needed like time,
date or hours and the file is been saved without this information.
How can I get a message box to tell me that one or all the range needed have
not been filled?
Thanks in advance.
Maperalia


Sub SaveExcelFile()

Dim Tract As String
Dim WO As String
Dim Supplier As String
Dim Dates As String
Dim Hours As String
Dim sFilename As String


WO = Worksheets("Gradation Form").Range("G2")
Tract = Worksheets("Gradation Form").Range("G3")
Supplier = Worksheets("Gradation Form").Range("C6")
Dates = Worksheets("Gradation Form").Range("G4")
Hours = Worksheets("Gradation Form").Range("G5")


Progname = "C:\Mario\VB\Excel\" & WO & "_" & Tract & "_" & Supplier &
"_" & Dates & "_" & Hours & ".xls"
ActiveWorkbook.SaveCopyAs Progname
End Sub

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Macro to save Excel file

How about adding something like:

Dim myRngToComplete as range


with worksheets("gradation form")
set myrngtocomplete = .range("G2:G5,C6")
end with

if myrngtocomplete.cells.count < application.counta(myrngtocomplete) then
msgbox "oh, oh! Cannot save!"
exit sub
end if



maperalia wrote:

I have a macro that saves an Excel file with specific name and path (see
below).
However, sometimes I forget the fill out the information needed like time,
date or hours and the file is been saved without this information.
How can I get a message box to tell me that one or all the range needed have
not been filled?
Thanks in advance.
Maperalia

Sub SaveExcelFile()

Dim Tract As String
Dim WO As String
Dim Supplier As String
Dim Dates As String
Dim Hours As String
Dim sFilename As String


WO = Worksheets("Gradation Form").Range("G2")
Tract = Worksheets("Gradation Form").Range("G3")
Supplier = Worksheets("Gradation Form").Range("C6")
Dates = Worksheets("Gradation Form").Range("G4")
Hours = Worksheets("Gradation Form").Range("G5")


Progname = "C:\Mario\VB\Excel\" & WO & "_" & Tract & "_" & Supplier &
"_" & Dates & "_" & Hours & ".xls"
ActiveWorkbook.SaveCopyAs Progname
End Sub


--

Dave Peterson
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 258
Default Macro to save Excel file

Dave;
Thank you very much it is working wonderful!!!!!!

"Dave Peterson" wrote:

How about adding something like:

Dim myRngToComplete as range


with worksheets("gradation form")
set myrngtocomplete = .range("G2:G5,C6")
end with

if myrngtocomplete.cells.count < application.counta(myrngtocomplete) then
msgbox "oh, oh! Cannot save!"
exit sub
end if



maperalia wrote:

I have a macro that saves an Excel file with specific name and path (see
below).
However, sometimes I forget the fill out the information needed like time,
date or hours and the file is been saved without this information.
How can I get a message box to tell me that one or all the range needed have
not been filled?
Thanks in advance.
Maperalia

Sub SaveExcelFile()

Dim Tract As String
Dim WO As String
Dim Supplier As String
Dim Dates As String
Dim Hours As String
Dim sFilename As String


WO = Worksheets("Gradation Form").Range("G2")
Tract = Worksheets("Gradation Form").Range("G3")
Supplier = Worksheets("Gradation Form").Range("C6")
Dates = Worksheets("Gradation Form").Range("G4")
Hours = Worksheets("Gradation Form").Range("G5")


Progname = "C:\Mario\VB\Excel\" & WO & "_" & Tract & "_" & Supplier &
"_" & Dates & "_" & Hours & ".xls"
ActiveWorkbook.SaveCopyAs Progname
End Sub


--

Dave Peterson

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
Save Macro in excel to be used on schedule file belvy123 Excel Discussion (Misc queries) 1 December 2nd 08 03:46 AM
internet connection via excel macro at timed intervels & save data to excel file. Sam Excel Worksheet Functions 1 July 22nd 07 06:08 AM
ASP: Open Excel File with Macro, Allow Macro to run, and then save delgados129 Excel Programming 0 March 10th 05 09:35 PM
Macro to save excel file jc lewis Excel Programming 1 June 25th 04 12:52 AM
Automate open file, update links, run macro, close and save file Geoff[_7_] Excel Programming 2 August 26th 03 10:13 PM


All times are GMT +1. The time now is 09:53 PM.

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

About Us

"It's about Microsoft Excel"