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
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
write code to save the worksheet in "This workbook" module, which is by default ceated.
us function
whenever you do anything in the sheet it will perform the code written inside the procedure.![]()
Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As Range) End Sub
though i will not advice what you are going to do as working on a sheet with continuous saving will be hell.
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
In case of a formula you could use Calculate (but that may be trigggered on any recalculation).![]()
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
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
@ AnkitGuru thanks mate
@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
@holger..
where should i use the calculate function??
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
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()).![]()
ActiveSheet.Range("C10").Calculate
Ciao,
Holger
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
Hi, Gokz,
amend the range to check if target meets the cells:
Ciao,![]()
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
Holger
Thanks HaHoBe
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks