+ Reply to Thread
Results 1 to 4 of 4

Save file by formula, criteria met, vba code

  1. #1
    Registered User
    Join Date
    02-06-2016
    Location
    Maryland
    MS-Off Ver
    2007
    Posts
    5

    Save file by formula, criteria met, vba code

    I have three workbooks open one with live data and the other two linked to it. I want one with linked data to save when criteria are met.
    Cell b2=if(or(b3="ok",b15="ok"...),1,0). When b2=1 save file.

    In VBA code I tried wksheet change, activate and if b2=1 activeworkbook.save.

    It only saves if I am typing on the sheet. It doesn't save when changed by formula. In other words if criteria met and b2=1 (changed by formula) doesn't' save file. This is the last thing I need and have been press save button but would like to automate.
    Welcome replies.
    Thanks

  2. #2
    Valued Forum Contributor bulina2k's Avatar
    Join Date
    11-20-2012
    Location
    Urziceni, Ialomita, Romania
    MS-Off Ver
    2019 and 365
    Posts
    867

    Re: Save file by formula, criteria met, vba code

    Hi there!
    My ideea is to use a static flag and to watch the value in B2 on every worksheet change event:
    Please Login or Register  to view this content.
    Hope it fits your needs...
    .. and don't forget to have fun!
    Bogdan.

    mark SOLVED and Add Reputation if my answer pleases you

  3. #3
    Registered User
    Join Date
    02-06-2016
    Location
    Maryland
    MS-Off Ver
    2007
    Posts
    5

    Re: Save file by formula, criteria met, vba code

    I tried this and the msgbox doesn't come up so 'not working' verified file isn't saved. I wonder if the sheet needs to be activated or something (b2) selected? thank you for the reply

  4. #4
    Registered User
    Join Date
    02-06-2016
    Location
    Maryland
    MS-Off Ver
    2007
    Posts
    5

    Re: Save file by formula, criteria met, vba code

    I did use part of you code and this appears to be working.
    [CODE]
    Private Sub Worksheet_Calculate()
    Application.EnableCancelKey = xlInterrupt
    Static save_flag As Boolean
    Dim test As Workbook
    Set test = Workbooks("test.xls")

    If Range("b2") = 0 Then save_flag = False

    If Range("b2") = 1 Then

    If save_flag = False Then

    test.Save
    save_flag = True


    End If

    End If

    End Sub
    [CODE]

+ 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] Vba Code to copy the formula file as values and save it another location
    By Masa1989 in forum Excel Programming / VBA / Macros
    Replies: 12
    Last Post: 08-05-2015, 07:30 AM
  2. [SOLVED] Need code to copy data based on filter criteria to new workbook as save in a file location
    By msantucci in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 02-24-2015, 02:47 AM
  3. [SOLVED] VBA code to save as file with specific file name
    By wolfm in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 12-10-2014, 10:45 AM
  4. [SOLVED] VBA code to save current worksheet as temporary PDF file and then add to my existing code
    By brianfromla in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 05-20-2014, 08:35 AM
  5. Macro to save a file, using particular criteria
    By bajdr47 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 04-29-2013, 07:49 PM
  6. Excel 2010 file with VBA save and send code works-but file can't be found.
    By carlton.clay in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 03-13-2013, 09:46 AM
  7. VBA Code to share file and save file
    By brian_2me in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 06-26-2012, 05:32 AM

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