View Single Post
  #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