Consulting

Results 1 to 4 of 4

Thread: Msg Box if cell left blank

  1. #1

    Msg Box if cell left blank

    Hello all,

    I have this working macro:

    Option Explicit
    Sub SaveAsExample()
    Dim FName As String
    Dim FPath As String
    FPath = "z:\i Wing\Names"
    FName = Format$(Date, "dd-mm-yyyy") & " " & Sheets("Sheet1").Range("H12").Text
    ThisWorkbook.SaveAs Filename:=FPath & "" & FName
    End Sub


    I would like to be able have a msg box if cell D48 has been left bank when the user tries to save, the messgae text is irrelevant... would this need to be a whole new macro or could it be included above: any thoughts...
    Last edited by Aussiebear; 09-08-2016 at 01:25 AM. Reason: Added code tags

  2. #2
    VBAX Expert Leith Ross's Avatar
    Joined
    Oct 2012
    Location
    San Francisco, California
    Posts
    552
    Location
    Hello Chris2460,

    Try this...
    Option Explicit
    
    
    Sub SaveAsExample()
    
    
    Dim FName As String
    Dim FPath As String
    
    
    If Sheets("Sheet1").Range("D48") <> "" Then
        FPath = "z:\i Wing\Names"
        FName = Format$(Date, "dd-mm-yyyy") & " " & Sheets("Sheet1").Range("H12").Text
        ThisWorkbook.SaveAs Filename:=FPath & "" & FName
    Else
        MsgBox "Some Data is Missing.", vbExclamation, "Workbook Not Saved"
    End If
    End Sub
    Sincerely,
    Leith Ross

    "1N73LL1G3NC3 15 7H3 4B1L17Y 70 4D4P7 70 CH4NG3 - 573PH3N H4WK1NG"

  3. #3
    Mmmmm, this saved as (Names08-09-2016)...... Do I need to create a seperate macro and then try to get the missing cell macro to run first followed by the Saveas example., along the lines of:

    Sub Msgbox
    If Sheets("Sheet1").Range("D48") <> "" Then 
    MsgBox "Some Data is Missing.", vbExclamation, "Workbook Not Saved" 
    EndSub
    I know this is not correct but you get the idea................. (Ihope) Cheers
    Last edited by Aussiebear; 09-08-2016 at 01:26 AM. Reason: Added code tags

  4. #4
    Sorry I might have posted this twice, I am getting there with the msg box, this now works perfect for me:
    Sub CheckIfCellIsEmpty()
    Dim isMyCellEmpty As Boolean
    isMyCellEmpty = IsEmpty(Range("D48"))
    If isMyCellEmpty = True Then
    MsgBox "Intelligence Report Requires Completing & the Box Selected"
    End If
    End Sub
    What I now need to do to complete the project is get this to run prio / inconjunction with:

    Sub Email()
    '
    ' Email Macro
    '
    '
        Application.Dialogs(xlDialogSendMail).Show
        ActiveWorkbook.Save
        Application.Goto Reference:="Email"
        ActiveSheet.Shapes.Range(Array("Rounded Rectangle 4")).Select
        Selection.OnAction = "Email"
        Range("L60").Select
        ActiveWindow.SmallScroll Down:=-57
        ActiveSheet.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True
    End Sub
    Any thoughts......

Posting Permissions

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