+ Reply to Thread
Results 1 to 3 of 3

macro to "save workbook" based on cell value

Hybrid View

  1. #1
    Forum Contributor
    Join Date
    11-14-2014
    Location
    uk
    MS-Off Ver
    Excel 2010
    Posts
    100

    macro to "save workbook" based on cell value

    I am trying to use this macro to "save workbook" only if one cell value is higher than another cell value

    is this possible ?


              With Worksheets("Dashboard")
    If .Range("N11").Value > .Range("N12").Value Then
    
    Application.Workbooks("Profit Maximizer.xlsm").Save
    
      End If
      End With

  2. #2
    Registered User
    Join Date
    11-18-2015
    Location
    Madrid
    MS-Off Ver
    2016
    Posts
    95

    Re: macro to "save workbook" based on cell value

    Hi! You can add this code to the Worksheet Object to run the macro automatically when cells N11 or N12 are changed:

    Private Sub Worksheet_Change(ByVal Target As Range)
    
    If Target.Address = "$N$11" Or Target.Address = "$N$12" Then
        If Range("N11").Value > Range("N12").Value Then
            ActiveWorkbook.Save
            MsgBox "The book has been saved!"
        End If
    End If
    
    End Sub
    excelbat.com: free Excel tools, macros...

  3. #3
    Forum Contributor
    Join Date
    11-14-2014
    Location
    uk
    MS-Off Ver
    Excel 2010
    Posts
    100

    Re: macro to "save workbook" based on cell value

    Thanks but the thing is my code is not working ,,,

    "N11" contains the formula =MOD(NOW(),1) and it is formatted as "ss" so it displays updated seconds
    "N12" containes the value 40

    my code is inside a macro that loops round continually, each loop taking aprox 3 mins but i don't want the workbook saved every 3 min's I only want the workbook to save every approximate hour, so if I make workbook save only if my second ticker N11 is above 40 then the number of saves will i hope be reduced

+ 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] Problem "save as" in a workbook with a macro
    By excelsoil in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 08-04-2015, 01:48 AM
  2. Problem running "Save macro to all workbook in folder"
    By calvinle in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 01-20-2014, 12:49 AM
  3. Create a Command Button to "Save As" and "Close" an Excel Workbook
    By thedunna in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 05-26-2013, 05:38 PM
  4. [SOLVED] Need a save and close macro that does not care if the "edit workbook" button has be clcked
    By rt3 in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 04-22-2013, 08:42 AM
  5. [SOLVED] "Stuck" - Macro to Save Workbook
    By Inez15 in forum Excel General
    Replies: 6
    Last Post: 12-04-2012, 02:14 PM
  6. [SOLVED] Macro to get worksheets to save to new workbook with OPEN workbooks .PATH & " " as name.
    By NicksDad in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 09-03-2012, 08:07 PM
  7. [SOLVED] save and restore "Workbook Menu Bar" & "Cell" menus
    By Jeff Higgins in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 02-13-2005, 10:08 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