+ Reply to Thread
Results 1 to 5 of 5

Calculate when cell changes

Hybrid View

  1. #1
    Forum Contributor
    Join Date
    04-21-2009
    Location
    England
    MS-Off Ver
    Excel 2016
    Posts
    710

    Calculate when cell changes

    Hi all, probably a bit of simple coding - but I would like my Excel sheet (set to manual refresh) to calculate when cell value "Y2" changes.

    Y2 is controlled by a data validation drop down, when the users changes the value I would like the sheet to refresh - rather than pressing F9.

    Thanks in advance

  2. #2
    Forum Expert
    Join Date
    09-27-2011
    Location
    Poland
    MS-Off Ver
    Excel 2007
    Posts
    1,312

    Re: Calculate when cell changes

    Hi
    try this in module of worksheet
    Private Sub Worksheet_Change(ByVal Target As Range)
    If Target.Address(0, 0) = "Y2" Then
    Application.Calculation = xlAutomatic
    Else:
    Application.Calculation = xlManual
    End If
    End Sub
    Regards

    tom1977

    If You are satisfied with my solution click the small star icon on the left to say thanks.

  3. #3
    Forum Expert Paul's Avatar
    Join Date
    02-05-2007
    Location
    Wisconsin
    MS-Off Ver
    2016/365
    Posts
    6,885

    Re: Calculate when cell changes

    Hi Cmb, the following code, placed within the specific worksheet's code module, should work for you:
    Private Sub Worksheet_Change(ByVal Target As Range)
    If Not Intersect(Target, Range("Y2")) Is Nothing Then ActiveSheet.Calculate
    End Sub

  4. #4
    Forum Contributor
    Join Date
    04-21-2009
    Location
    England
    MS-Off Ver
    Excel 2016
    Posts
    710

    Re: Calculate when cell changes

    Hi both, great they do what I asked. My next problem (and one I didn;t factor in) is that I also want the same thing to happen if data is changed in cells Z58:Z81.

    I assumed I could just copy the code you have provided above and add it to the bottom with the new range - but it doesn;t appear to work.

    Any help on that?

    Thanks again

  5. #5
    Forum Expert
    Join Date
    09-27-2011
    Location
    Poland
    MS-Off Ver
    Excel 2007
    Posts
    1,312

    Re: Calculate when cell changes

    Private Sub Worksheet_Change(ByVal Target As Range)
    If Not Intersect(Target, Union(Range("Y2"), Range("Z58:Z81"))) Is Nothing Then ActiveSheet.Calculate
    End Sub

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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