+ Reply to Thread
Results 1 to 2 of 2

How do I save a specified sheet (not active) but also have a prompt msgbox for it?

  1. #1
    Registered User
    Join Date
    07-31-2015
    Location
    Scotland
    MS-Off Ver
    2013
    Posts
    1

    How do I save a specified sheet (not active) but also have a prompt msgbox for it?

    Hi Guys,

    I am really new to VBA and I am sure this question has been asked but all the answers I have seen don't quite add up to what I am trying to do...

    I can find ways to save the entire workbook and save it to its original folder but I want it to save a COPY of a specific sheet to a specified folder and prompt a message box asking whether it does actually want to save.

    All I have managed to do so far is get it to prompt a message but the sheet has already saved.

    This is what I have so far:

    Sub Save_Job_Sheet()

    Dim FName As String
    Dim FPath As String
    Dim NewBook As Workbook

    FPath = "C:\Users\WhyFar"
    FName = "Job" & " " & Format(Date, "dd-mm-yy") & ".xlsx"

    Set NewBook = Workbooks.Add

    ThisWorkbook.Sheets(1).Copy Before:=NewBook.Sheets(1)

    If Dir(FPath & "\" & FName) <> "" Then
    MsgBox "File " & FPath & "\" & FName & " already exists"
    Else
    NewBook.SaveAs Filename:=FPath & "\" & FName
    End If

    ' Pops up message

    Dim Sure As Integer

    If Not ThisWorkbook.Saved Then
    If MsgBox("Save File?", vbYesNo, "Saving") = vbYes Then
    ThisWorkbook.Save
    End If
    End If

    End Sub

    I know the bit that pops up the message is saving the workbook but i can't work out how to change that either?

    Cheers

    WhyFar

  2. #2
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: How do I save a specified sheet (not active) but also have a prompt msgbox for it?

    Hi WhyFar,

    Welcome to the Forum!

    Maybe:

    Please Login or Register  to view this content.
    BTW -
    Your post does not comply with Rule 3 of our Forum RULES. Use code tags around code.

    Posting code between [CODE]Please [url=https://www.excelforum.com/login.php]Login or Register [/url] to view this content.[/CODE] tags makes your code much easier to read and copy for testing, it also maintains VBA formatting.

    Highlight your code and click the # icon at the top of your post window. More information about these and other tags can be found here
    If I've helped you, please consider adding to my reputation - just click on the liitle star at the left.

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~(Pride has no aftertaste.)

    You can't do one thing. XLAdept

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~aka Orrin

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] save active sheet in new workbook, naming it as cell value of active sheet
    By arkharova.s in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 02-18-2014, 06:16 AM
  2. Only "save" option in save prompt while closing excel sheet
    By rudswa in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 09-30-2013, 08:07 PM
  3. [SOLVED] VBA to save active sheet as new file with save as option
    By Gti182 in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 08-14-2013, 10:54 AM
  4. Save Active workbook, Add a password via a prompt and stop creating backups
    By dlast in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 05-01-2013, 05:59 AM
  5. [SOLVED] Save sheet in new workbook without prompt
    By VBA FTW in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 09-20-2012, 03:17 PM
  6. [SOLVED] how to prompt out certain range of table in active sheet
    By onestar in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 07-05-2012, 12:15 AM
  7. Macro to save sheet as .txt also prompt window to generate filename
    By rain4u in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 04-19-2011, 08:18 PM
  8. Replies: 1
    Last Post: 02-24-2006, 10:15 PM

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