+ Reply to Thread
Results 1 to 10 of 10

Macro to save a workbook when a cell value changes!!

Hybrid View

gokzee Macro to save a workbook... 12-07-2012, 02:23 AM
AnkitGuru Re: Macro to save a workbook... 12-07-2012, 02:33 AM
HaHoBe Re: Macro to save a workbook... 12-07-2012, 02:41 AM
gokzee Re: Macro to save a workbook... 12-07-2012, 03:39 AM
gokzee Re: Macro to save a workbook... 12-07-2012, 03:34 AM
gokzee Re: Macro to save a workbook... 12-07-2012, 03:51 AM
HaHoBe Re: Macro to save a workbook... 12-07-2012, 04:35 AM
gokzee Re: Macro to save a workbook... 12-07-2012, 05:17 AM
HaHoBe Re: Macro to save a workbook... 12-07-2012, 06:55 AM
gokzee Re: Macro to save a workbook... 12-11-2012, 04:21 AM
  1. #1
    Forum Contributor
    Join Date
    11-08-2012
    Location
    Dubai
    MS-Off Ver
    Excel For Mac V16 365
    Posts
    145

    Macro to save a workbook when a cell value changes!!

    Hello!!

    i am looking for a macro that can automatically save the workbook when a cell value changes for ex: cell C10


    many thanks

    Gokz

  2. #2
    Registered User
    Join Date
    02-28-2012
    Location
    India
    MS-Off Ver
    Excel 2007
    Posts
    14

    Re: Macro to save a workbook when a cell value changes!!

    write code to save the worksheet in "This workbook" module, which is by default ceated.

    us function

    Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As Range)
    
    End Sub
    whenever you do anything in the sheet it will perform the code written inside the procedure.

    though i will not advice what you are going to do as working on a sheet with continuous saving will be hell.

  3. #3
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 365 on Win11 (desktop), 2019 on Win11 (notebook)
    Posts
    8,198

    Re: Macro to save a workbook when a cell value changes!!

    Hi, Gokz ,

    will that value change by typing in new contnets or by using a Formula?

    Code goes behind the Sheet, Right-Click Tab and View Code
    Private Sub Worksheet_Change(ByVal Target As Range)
    If Target.Count > 1 Then Exit Sub
    If Not Intersect(Target, Range("C10")) Is Nothing Then
      ThisWorkbook.Save
    End If
    End Sub
    In case of a formula you could use Calculate (but that may be trigggered on any recalculation).

    Ciao,
    Holger
    Use Code-Tags for showing your code: [code] Your Code here [/code]
    Please mark your question Solved if there has been offered a solution that works fine for you

  4. #4
    Forum Contributor
    Join Date
    11-08-2012
    Location
    Dubai
    MS-Off Ver
    Excel For Mac V16 365
    Posts
    145

    Re: Macro to save a workbook when a cell value changes!!

    @ AnkitGuru thanks mate

  5. #5
    Forum Contributor
    Join Date
    11-08-2012
    Location
    Dubai
    MS-Off Ver
    Excel For Mac V16 365
    Posts
    145

    Re: Macro to save a workbook when a cell value changes!!

    @holger..


    actually..the worksheet will automatically pop up using windows scheduler....pick up the value from net using formula...in c10...

    Once value in c10 is changed...it should run the macro and save.

    hw will the trigger affect in this case. for any recalculation in the sheet??

    thanks

    Gokz

  6. #6
    Forum Contributor
    Join Date
    11-08-2012
    Location
    Dubai
    MS-Off Ver
    Excel For Mac V16 365
    Posts
    145

    Re: Macro to save a workbook when a cell value changes!!

    @holger..

    where should i use the calculate function??

  7. #7
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 365 on Win11 (desktop), 2019 on Win11 (notebook)
    Posts
    8,198

    Re: Macro to save a workbook when a cell value changes!!

    Hi, Gokz,

    depending on how the data is collected from the Net maybe you must wait for the actualisation having taken place. You didn´t mention if and how this process is started - maybe you can read in the value from the cell on opening and compare it to the actual value of the cell when the process is finished.

    Right-Click on Worksheet Tab, Select Worksheet in left combobox and Calculate on the right. Event will be raised if any recalculation in the worksheet is done. If the event isn´t triggered (due to the scheduler starting Excel) and you use a macro to start the process you could apply
    ActiveSheet.Range("C10").Calculate
    to start the calculation at the end of the macro. This would mean that a volatile formula is part of the worksheet (like Today(), Now()).

    Ciao,
    Holger

  8. #8
    Forum Contributor
    Join Date
    11-08-2012
    Location
    Dubai
    MS-Off Ver
    Excel For Mac V16 365
    Posts
    145

    Re: Macro to save a workbook when a cell value changes!!

    there will be a software that is running always...so as soon as the scheduler opens the excel file...the excel file picks up the values from ths software.

    then macro should save. this is the process..

    so i think the "change" will be enough instead of calculate.

    but what if i have more than one cell that is updating the values maybe for 6 cells...hw will that scenario be??


    thanks


    gokz

  9. #9
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 365 on Win11 (desktop), 2019 on Win11 (notebook)
    Posts
    8,198

    Re: Macro to save a workbook when a cell value changes!!

    Hi, Gokz,

    amend the range to check if target meets the cells:
    Private Sub Worksheet_Change(ByVal Target As Range)
    If Target.Count > 1 Then Exit Sub
    If Not Intersect(Target, Range("C10,E12,G14")) Is Nothing Then
      ThisWorkbook.Save
    End If
    End Sub
    Ciao,
    Holger

  10. #10
    Forum Contributor
    Join Date
    11-08-2012
    Location
    Dubai
    MS-Off Ver
    Excel For Mac V16 365
    Posts
    145

    Re: Macro to save a workbook when a cell value changes!!

    Thanks HaHoBe

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Tags for this Thread

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