VBA Auto save

blossomthe2nd

Active Member
Joined
Oct 11, 2010
Messages
450
Hi Guys,

I have a worksheet , where from a drop down in Cell B2, a mcro runs hiding certain columns and formats sheet, see code below.

As this is a Shared workbook with multiple users, I would like to add the function that after B2 is selected the file Autosaves -- Is there a code for this ?
Code:
Private Sub Worksheet_Change(ByVal Target As Range)
    If Target.Address <> "$B$1" Then Exit Sub
    Dim LR As Long
    If InStr("out_of_course drawdowns customer_service", LCase(Target.Value)) > 0 Then
        Columns("C:G").EntireColumn.Hidden = True
    Else
        Columns("C:G").EntireColumn.Hidden = False
    End If
    If InStr("rollovers", LCase(Target.Value)) > 0 Then
        Columns("i:K").EntireColumn.Hidden = True
    Else
        Columns("i:K").EntireColumn.Hidden = False
    End If
    If InStr("out_of_course drawdowns rollovers", LCase(Target.Value)) > 0 Then
        Columns("L:N").EntireColumn.Hidden = True
    Else
        Columns("L:N").EntireColumn.Hidden = False
    End If
    If InStr("customer_service drawdowns rollovers", LCase(Target.Value)) > 0 Then
        Columns("O:q").EntireColumn.Hidden = True
    Else
        Columns("O:q").EntireColumn.Hidden = False
    End If
    If InStr("customer_service rollovers", LCase(Target.Value)) > 0 Then
        Columns("R").EntireColumn.Hidden = True
    Else
        Columns("R").EntireColumn.Hidden = False
    End If
    If InStr("customer_service rollovers out_of_course", LCase(Target.Value)) > 0 Then
        Columns("s:Z").EntireColumn.Hidden = True
    Else
        Columns("s:Z").EntireColumn.Hidden = False
    End If
    If InStr("rollovers drawdowns", LCase(Target.Value)) > 0 Then
        Columns("h").EntireColumn.Hidden = True
    Else
        Columns("h").EntireColumn.Hidden = False
    End If
    LR = Range("A" & Rows.Count).End(xlUp).Row + 1
    Application.Goto Range("A" & LR), True
End Sub
 

Excel Facts

Links? Where??
If Excel says you have links but you can't find them, go to Formulas, Name Manager. Look for old links to dead workbooks & delete.
I'm going to say

<CODE>ActiveWorkbook.Save</CODE></PRE>
<CODE>but this seems like it may be creating a semi-volitile situation in a multi-user file. </CODE></PRE>
<CODE></CODE> </PRE>
<CODE></CODE> </PRE>
 
Upvote 0
Hi Tweedle,

Thanks for your response , is it possible to hook that up with , if call range A : A changes then auto save ?

Code:
If Target.Address <> "A:A" Then ThisWorkbook.Save

I have it like the above , but that saves after every cell is updated !!

Please help !!

Thanks
 
Upvote 0
Depending on what you're after...

If Target.Column = 1 then 'Act only when Target is Column A

OR

If Target.Column <> 1 then 'Act only when Target is not Column A
 
Upvote 0

Forum statistics

Threads
1,224,600
Messages
6,179,834
Members
452,947
Latest member
Gerry_F

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