+ Reply to Thread
Results 1 to 9 of 9

Change code to require a Response

Hybrid View

  1. #1
    Forum Expert Paul's Avatar
    Join Date
    02-05-2007
    Location
    Wisconsin
    MS-Off Ver
    2016/365
    Posts
    6,887

    Re: Change code to require a Response

    You forgot to keep in the "Exit Sub" before the "End If". Also, it's great that you created all of those variables. If you want to continue using them you can, but it could also be setup like the following (also added a check to ensure there was a valid date in F2):
    Sub NameIt()
    With Sheets("Log In Screen")
        If .Range("F2") = "" Or .Range("D6") = "" Or .Range("I6") = "" Then
            MsgBox "You haven't filled in the Date, MEDIC# and/or Crew yet."
            Exit Sub
        ElseIf Not IsDate(.Range("F2").Value) Then
            MsgBox "The Date (F2) is not valid."
            Exit Sub
        Else
            ActiveWorkbook.SaveAs Filename:= _
            "C:\Users\Brian\Desktop\Excell Test Folder\" & _
            Format(.Range("F2").Value, "m-d-yyyy") & "-" & _
            CStr(.Range("I6").Value) & "-" & CStr(.Range("D6").Value) & ".xlsm", _
            FileFormat:=xlOpenXMLWorkbookMacroEnabled
        End If
    End With
    End Sub
    Last edited by Paul; 04-22-2012 at 06:09 AM.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1