Update on Any Changes

fad1959

New Member
Joined
Apr 30, 2003
Messages
45
Can i save a Worksheet or Workbook,

Only when there are changes made in say Cells C3:D30 on a shared Workbook


The problem:

Shared workbook doesn't seem to update when other users make changes.

will it work instantaneously with any changes in mentioned cells

I've been to Tools>Share Work book menu

Thank you
Frank
 

Excel Facts

How to calculate loan payments in Excel?
Use the PMT function: =PMT(5%/12,60,-25000) is for a $25,000 loan, 5% annual interest, 60 month loan.
I don't think that this will be real user firendly if your wb is substantially sized due to the amount of time taken when saving, but it will save the wb whenever a change is made in C3:D30:

<font face=Tahoma><SPAN style="color:#00007F">Private</SPAN> <SPAN style="color:#00007F">Sub</SPAN> Worksheet_Change(<SPAN style="color:#00007F">ByVal</SPAN> Target <SPAN style="color:#00007F">As</SPAN> Range)
    <SPAN style="color:#00007F">Dim</SPAN> rng <SPAN style="color:#00007F">As</SPAN> Range
     <SPAN style="color:#007F00">'   Only look at single cell changes</SPAN>
    <SPAN style="color:#00007F">If</SPAN> Target.Count > 1 <SPAN style="color:#00007F">Then</SPAN> <SPAN style="color:#00007F">Exit</SPAN> <SPAN style="color:#00007F">Sub</SPAN>
    <SPAN style="color:#00007F">Set</SPAN> rng = Range("C3:D30")
    <SPAN style="color:#007F00">'   Only look at that range</SPAN>
    <SPAN style="color:#00007F">If</SPAN> Intersect(Target, rng) <SPAN style="color:#00007F">Is</SPAN> <SPAN style="color:#00007F">Nothing</SPAN> <SPAN style="color:#00007F">Then</SPAN> <SPAN style="color:#00007F">Exit</SPAN> <SPAN style="color:#00007F">Sub</SPAN>
        ActiveWorkbook.Save
<SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">Sub</SPAN></FONT>

Note that you'll need to unshare the wb to get the code in as VB projects aren't available in shareed mode.

As for why changes aren't being reflected, could it be that users aren't saving?

You could also force saving with:

<font face=Tahoma><SPAN style="color:#00007F">Private</SPAN> <SPAN style="color:#00007F">Sub</SPAN> Workbook_BeforeClose(Cancel <SPAN style="color:#00007F">As</SPAN> <SPAN style="color:#00007F">Boolean</SPAN>)
    Application.DisplayAlerts = <SPAN style="color:#00007F">False</SPAN>
        ActiveWorkbook.Save
    Application.DisplayAlerts = <SPAN style="color:#00007F">True</SPAN>
<SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">Sub</SPAN></FONT>

If you've got questions on what to do with the code, post back.

Hope that helps,

Smitty
 
Upvote 0
Thanks Smitty,

I used this code in thisworkbook and it seems to work pretty good but it

would work better if it can update every minute i think


Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As Range)
Application.DisplayAlerts = False
ActiveWorkbook.Save
Application.DisplayAlerts = True
End Sub
 
Upvote 0
Does this work?
Code:
Private Sub Worksheet_Change(ByVal Target As Range)

Dim strNow As String
Dim rowTgt As Long
Dim valTgt
Dim ws As Worksheet
Dim rngC As Range
Dim rngD As Range
Dim SaveFlag As Boolean

    If Target.Column <> 2 Then
        Exit Sub
    End If
    
    If Target.Row < 3 Or Target.Row > 30 Then
        Exit Sub
    End If

    SaveFlag = True
    strNow = Format(Now(), "hh:mm:ss AMPM")

    rowTgt = Target.Row
    
    Set ws = Sheets("Sheet1")
    Set rngC = ws.Range("C" & rowTgt)
    Set rngD = ws.Range("D" & rowTgt)
    
    valTgt = Target.Value
    
    Select Case valTgt
    
        Case "IN OFFICE"
            rngD = strNow
            rngC = ""
        Case "Depart Lunch/Road Sup", "Out Of Office"
            rngC = strNow
        Case "Return Lunch/Road Sup", "Return From Meeting", "Return From Lunch"
            rngD = strNow
        Case "Out For Lunch"
            rngC = strNow
            rngD = ""
        Case Else
            rngC = ""
            rngD = ""
            SaveFlag = False
            
    End Select
    
    If SaveFlag Then
        Application.DisplayAlerts = False
        ActiveWorkbook.Save
        Application.DisplayAlerts = True
    End If
End Sub
 
Upvote 0

Forum statistics

Threads
1,203,317
Messages
6,054,706
Members
444,742
Latest member
jmartin9247

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top