Results 1 to 3 of 3

Thread: SaveAs Error

  1. #1
    Acolyte tigerdel's Avatar
    Join Date
    Aug 2012
    Location
    Cambridgeshire
    Posts
    34
    Articles
    0
    Excel Version
    Office 365

    SaveAs Error



    Register for a FREE account, and/
    or Log in to avoid these ads!

    I have tried to get the below code working but I have obviously done something wrong as although I get no error messages I am not getting the second part to trigger

    The first part does what it should do bit the second part doesn't trigger the msgboxes

    Any ideas what I am doing wrong??

    Code:
    Sub SaveSheet()
    Range("BB1").Select
    If Range("BB1").Value = "TRUE" Then 'check cell content and if TRUE trigger msgbox
    MsgBox ("Your DCW contains Data" & vbNewLine & "Ensure you have saved your file before closing")
    If MsgBox("To Save your work, Click Yes" & vbNewLine & "To quit without saving, Click No", vbYesNo) = vbYes Then
    Application.Dialogs(xlDialogSaveAs).Show "C:\Temp\" & Sheets("DCW").Range("E1").Value & " - " & Format(Date, "dd-mmm-yyyy") & ".xlsb"
    Else
    Range("BB1").Select
    If Range("BB1").Value = "FALSE" Then 'If contains FALSE
    MsgBox ("You can Close this WorkBook without saving")
    If MsgBox("To Save your work, Click Yes" & vbNewLine & "To quit without saving, Click No", vbYesNo) = vbYes Then
    Application.Dialogs(xlDialogSaveAs).Show "C:\Temp\" & Sheets("DCW").Range("E1").Value & " - " & Format(Date, "dd-mmm-yyyy") & ".xlsb"
    Else
    MsgBox ("This application will now close")
    ActiveWorkbook.Close False
    End If
    End If
    End If
    End If
    End Sub
    Last edited by Bob Phillips; 2012-09-26 at 12:37 AM. Reason: Code tags

  2. #2
    Try this

    Code:
    Sub SaveSheet()
        If Range("BB1").Value = "TRUE" Then 'check cell content and if TRUE trigger msgbox
            MsgBox ("Your DCW contains Data" & vbNewLine & "Ensure you have saved your file before closing")
            If MsgBox("To Save your work, Click Yes" & vbNewLine & _
                      "To quit without saving, Click No", vbYesNo) = vbYes Then
                Application.Dialogs(xlDialogSaveAs).Show "C:\Temp\" & Sheets("DCW").Range("E1").Value & " - " & _
                                                         Format(Date, "dd-mmm-yyyy") & ".xlsb"
            Else
                MsgBox ("This application will now close")
                ActiveWorkbook.Close False
            End If
        ElseIf Range("BB1").Value = "FALSE" Then 'If contains FALSE
            MsgBox ("You can Close this WorkBook without saving")
            If MsgBox("To Save your work, Click Yes" & vbNewLine & _
                      "To quit without saving, Click No", vbYesNo) = vbYes Then
                Application.Dialogs(xlDialogSaveAs).Show "C:\Temp\" & Sheets("DCW").Range("E1").Value & " - " & _
                                                         Format(Date, "dd-mmm-yyyy") & ".xlsb"
            Else
                MsgBox ("This application will now close")
                ActiveWorkbook.Close False
            End If
        End If
    End Sub

  3. #3
    Acolyte tigerdel's Avatar
    Join Date
    Aug 2012
    Location
    Cambridgeshire
    Posts
    34
    Articles
    0
    Excel Version
    Office 365
    Absolute star
    May be you can also help with post
    Copy Sheet to New File but Remove all Buttons

Posting Permissions

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