LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
Jan Jan is offline
external usenet poster
 
Posts: 159
Default Before macro runs - check workbook name

Hello All,
I am using Excel 97 and need some help with VBA as I don't know it all that
well.

Before the below macro is run, the end user needs to save the workbook as
CSRreport.xls. However, some users forget to save the workbook under the new
name before running the macro, which then causes a problem with the original
file (workbook).

I need the macro (below) to first check that the workbook is named
€œCSRreport.xls€ before the rest of the code continues. How can I add to the
following code at the beginning to check that the workbook name is
€œCSRreport.xls€ and if it isnt, display a message box informing the user to
save the file as €œCSRreport.xls and try the macro again.


Sub CSRreport()
' CSRreport Macro
' Macro recorded 5/10/2006
'
If Worksheets("PastDue").Visible = True Then
Worksheets("PastDue").Visible = False
End If

Worksheets("Label Number").Select
Range("U3").Select
CSRFilter
CSRPrintarea
Range("A:A,D:D,F:G,J:M,S:S,T:T,U:U,V:V,W:W,X:X,Y:Y ,Z:Z,AA:AA").Select
Range("AA2").Activate
Selection.EntireColumn.Hidden = True
CSRTitle

End Sub

TIA
Jan
 
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
VBA macro runs fine, but freezes if I try to do ANYTHING else whileit runs Rruffpaw Setting up and Configuration of Excel 1 September 17th 11 01:25 PM
how to create a macro that runs other macro in the same workbook VB Script for Excel Excel Programming 4 March 23rd 06 03:53 AM
Macro runs in source , but not when in Personal Macro Workbook Darin Kramer Excel Programming 1 September 13th 05 04:48 PM
Excel Workbook automatically (by design) runs a macro Paul Excel Programming 0 August 5th 04 10:49 PM
Excel Workbook automatically (by design) runs a macro Chip Pearson Excel Programming 0 August 5th 04 08:24 PM


All times are GMT +1. The time now is 07:28 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"