+ Reply to Thread
Results 1 to 7 of 7

Problem with calculating

  1. #1
    Registered User
    Join Date
    10-25-2004
    Posts
    12

    Problem with calculating

    I have a spreadsheet in which I'm trying to prevent users from accidentally modifying cells containing formulas. On occasion, however, they will need to manually input data instead of allowing the formula to calculate. Using info found on this forum I put
    Please Login or Register  to view this content.
    into the worksheet. frmChange.Show asks the user if s/he would like to change the contents of the cell and contains
    Please Login or Register  to view this content.
    This works perfectly for me accept that if the user clicks 'Yes' then the entire workbook recalculates. Having had other recalculation problems in the past, is there a way to prevent the recalculation of the entire worksheet? Basically what I'm looking for is a way to get the same effect as setting Calculation to Manual, except that during the course of normal data entry I need the cells containing formulas to calculate.
    Last edited by Prometheus; 09-23-2005 at 04:09 PM.

  2. #2
    Registered User
    Join Date
    10-25-2004
    Posts
    12
    I saw a reference to setting xcalculation to semiautomatic but I can't seem to get that to work, any suggestions?

  3. #3
    Dave Peterson
    Guest

    Re: Problem with calculating

    Are you asking if you can stop the worksheet from recalculating when you
    clearcontents of the cell?

    You could turn calculation off, clear the contents, then turn calculation back
    on when the user selects another cell--but that sounds dangerous to me.

    I guess my question is why bother clearing the cell at all. Just let them type
    the new entry.

    =====
    Another option I've used when I want to give users a chance to override formulas
    is to use multiple cells.

    Say I a formula in C12.
    I'd use D12 as the User Input Cell
    Then I'd use this is E12:
    =if(d12="",c12,d12)

    And have every subsequent formulas point at E12 (since that contains the results
    of the formula or the user override).

    Prometheus wrote:
    >
    > I have a spreadsheet in which I'm trying to prevent users from
    > accidentally modifying cells containing formulas. On occasion,
    > however, they will need to manually input data instead of allowing the
    > formula to calculate. Using info found on this forum I put
    >
    > Code:
    > --------------------
    >
    > Private Sub Worksheet_SelectionChange(ByVal Target As Range)
    > Const WS_RANGE As String = "D9:O9"
    > On Error Resume Next
    > If Not Intersect(Target, Me.Range(WS_RANGE)) Is Nothing Then
    > Application.ScreenUpdating = False
    > frmChange.Show
    > Application.ScreenUpdating = True
    > End If
    > End Sub
    >
    > --------------------
    >
    > into the worksheet. frmChange.Show asks the user if s/he would like to
    > change the contents of the cell and contains
    >
    > Code:
    > --------------------
    >
    > Private Sub cmdNo_Click()
    > ActiveCell.Offset(1, 0).Select
    > Unload Me
    > End Sub
    >
    > Private Sub cmdYes_Click()
    > ActiveCell.ClearContents
    > Unload Me
    > End Sub
    >
    > Code:
    > --------------------
    >
    > This works perfectly for me accept that if the user clicks 'Yes' then the entire workbook recalculates. Having had other recalculation problems in the past, is there a way to prevent the recalculation of the entire worksheet? Basically what I'm looking for is a way to get the same effect as setting Calculation to Manual, except that during the course of normal data entry I need the cells containing formulas to calculate.
    >
    > --
    > Prometheus
    > ------------------------------------------------------------------------
    > Prometheus's Profile: http://www.excelforum.com/member.php...o&userid=15697
    > View this thread: http://www.excelforum.com/showthread...hreadid=470342


    --

    Dave Peterson

  4. #4
    Registered User
    Join Date
    10-25-2004
    Posts
    12
    Excellent, thanks for the tip. I thought it would be nice to clear the cell for the user but didn't realize that was causing the recalculation. One other question I have is if it's possible to declare more than one range in the code
    Please Login or Register  to view this content.
    For example, is there a way to set the range as D9:09, D13:013, D15:015, etc, without creating a new sub for each?
    Last edited by Prometheus; 09-26-2005 at 01:52 PM.

  5. #5
    Dave Peterson
    Guest

    Re: Problem with calculating

    Const WS_RANGE As String = "D9:O9,"X1:y2"

    would be one way.

    Prometheus wrote:
    >
    > Excellent, thanks for the tip. I thought it would be nice to clear the
    > cell for the user but didn't realize that was causing the
    > recalculation. One other question I have is if it's possible to
    > declare more than one range in the code
    >
    > Code:
    > --------------------
    >
    > Private Sub Worksheet_SelectionChange(ByVal Target As Range)
    >
    > Const WS_RANGE As String = "D9:O9"
    > On Error Resume Next
    > If Not Intersect(Target, Me.Range(WS_RANGE)) Is Nothing Then
    > Application.ScreenUpdating = False
    > frmChange.Show
    > End If
    >
    > End Sub
    >
    > --------------------
    >
    > For example, is there a way to set the range as D9:09, D13:013,
    > D15:015, etc, without creating a new sub for each?
    >
    > --
    > Prometheus
    > ------------------------------------------------------------------------
    > Prometheus's Profile: http://www.excelforum.com/member.php...o&userid=15697
    > View this thread: http://www.excelforum.com/showthread...hreadid=470342


    --

    Dave Peterson

  6. #6
    Dave Peterson
    Guest

    Re: Problem with calculating

    And if that increment were nice, you could even use some arithmetic:

    Option Explicit
    Private Sub Worksheet_SelectionChange(ByVal Target As Range)

    If Intersect(Target, Me.Range("d:o")) Is Nothing Then Exit Sub

    If Target.Row < 9 Then Exit Sub
    If Target.Row Mod 4 <> 1 Then Exit Sub

    Application.ScreenUpdating = False
    frmChange.Show
    Application.ScreenUpdating = True

    End Sub

    This got row 9, 13, 17, 21, ...

    (I didn't see a pattern with your sample.)


    Prometheus wrote:
    >
    > Excellent, thanks for the tip. I thought it would be nice to clear the
    > cell for the user but didn't realize that was causing the
    > recalculation. One other question I have is if it's possible to
    > declare more than one range in the code
    >
    > Code:
    > --------------------
    >
    > Private Sub Worksheet_SelectionChange(ByVal Target As Range)
    >
    > Const WS_RANGE As String = "D9:O9"
    > On Error Resume Next
    > If Not Intersect(Target, Me.Range(WS_RANGE)) Is Nothing Then
    > Application.ScreenUpdating = False
    > frmChange.Show
    > End If
    >
    > End Sub
    >
    > --------------------
    >
    > For example, is there a way to set the range as D9:09, D13:013,
    > D15:015, etc, without creating a new sub for each?
    >
    > --
    > Prometheus
    > ------------------------------------------------------------------------
    > Prometheus's Profile: http://www.excelforum.com/member.php...o&userid=15697
    > View this thread: http://www.excelforum.com/showthread...hreadid=470342


    --

    Dave Peterson

  7. #7
    Registered User
    Join Date
    10-25-2004
    Posts
    12
    Well if there's a mathematical formula to determine the location of the rows I need to protect I'm not smart enough to figure it out. However, the first example was just what I needed, thanks.

+ 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