+ Reply to Thread
Results 1 to 5 of 5

Cell calculation not responding?

Hybrid View

  1. #1
    Forum Contributor
    Join Date
    07-05-2016
    Location
    cardiff
    MS-Off Ver
    2010
    Posts
    787

    Cell calculation not responding?

    Hi,

    I have a simple calculation which has worked in the past but seems to have stopped working. I was advised to paste
    Application.Enableevents = True
    in the intermediate window which kick started the program but
    I require greater reliability. I've checked the target cells and everything looks fine. Can anyone see whats up?




    Private Sub Worksheet_Change(ByVal Target As Range)
        Application.EnableEvents = False
    
        If Range("N13").Value = "A" Then
            Range("N15").Value = 23
            
            End If
    
       If Range("N13").Value = "C" Then
            Range("N15").Value = 39
           
             End If
        If Range("N13").Value = "E" Then
            Range("N15").Value = 39
            
            End If
    
       If Range("N13").Value = "G" Then
            Range("N15").Value = 68.5
              End If
            
        If Range("N13").Value = "H" Then
            Range("N15").Value = 68.5
            
            End If
            
        If Range("N13").Value = "J" Then
            Range("N15").Value = "67"
            
            End If
    
       If Range("N13").Value = "N" Then
            Range("N15").Value = 47
            
              End If
              
        If Range("N13").Value = "P" Then
            Range("N15").Value = 10
            
            End If
    
       If Range("N13").Value = "R" Then
            Range("N15").Value = 56
            
            End If
            
             If Range("N13").Value = "T" Then
            Range("N15").Value = 43.5
              End If
            
       If Range("N13").Value = "V" Then
            Range("N15").Value = 73
            
              End If
              
        If Range("N13").Value = "X" Then
            Range("N15").Value = 8.5
            
            End If
    
       If Range("N13").Value = "Y" Then
            Range("N15").Value = 10.5
            
             End If
             
    
    'IVE ADDED A MM TO CONFORM TO CST
    
       If Range("N25").Value = "STUBJ014" Then
            Range("N26").Value = 211
            
                     End If
          'IVE ADDED A MM TO CONFORM TO CST
                     
            If Range("N25").Value = "STUBJ015" Then
            Range("N26").Value = 196
            
                     End If
    
      
    End Sub

  2. #2
    Valued Forum Contributor
    Join Date
    11-26-2012
    Location
    Sydney
    MS-Off Ver
    2010
    Posts
    423

    Re: Cell calculation not responding?

    You've set Application.EnableEvents = False at the top of the module. It will stay that way until you set it to true (or restart Excel). Using the Immediate Window is perfectly fine for debugging, but you've got to fix the code too, by putting Application.EnableEvents = True at the end of the module.

  3. #3
    Forum Guru xlnitwit's Avatar
    Join Date
    06-27-2016
    Location
    London
    MS-Off Ver
    Windows: 2010; Mac: 16.13 (O365)
    Posts
    7,085

    Re: Cell calculation not responding?

    Hi,

    The way that code is written, it will test N13 against all of those values, even after matching one of them. I'd suggest this
    Private Sub Worksheet_Change(ByVal Target As Range)
        Dim theValue              As Double
        On Error GoTo finish
        Application.EnableEvents = False
    
        Select Case UCase$(Range("N13").Value)
            Case "A"
                theValue = 23
            Case "C", "E"
                theValue = 39
            Case "G", "H"
                theValue = 68.5
            Case "J"
                theValue = 67
            Case "N"
                theValue = 47
            Case "P"
                theValue = 10
            Case "R"
                theValue = 56
            Case "T"
                theValue = 43.5
            Case "V"
                theValue = 73
            Case "X"
                theValue = 8.5
            Case "Y"
                theValue = 10.5
    
        End Select
    
        If theValue <> 0 Then Range("N15").Value2 = theValue
        
        'IVE ADDED A MM TO CONFORM TO CST
    
        If Range("N25").Value2 = "STUBJ014" Then
            Range("N26").Value2 = 211
    
        ElseIf Range("N25").Value2 = "STUBJ015" Then
            Range("N26").Value2 = 196
        End If
    finish:
        Application.EnableEvents = True
    End Sub
    Don
    Please remember to mark your thread 'Solved' when appropriate.

  4. #4
    Forum Contributor
    Join Date
    07-05-2016
    Location
    cardiff
    MS-Off Ver
    2010
    Posts
    787

    Re: Cell calculation not responding?

    Thanks Lads, sorry for delay, up to my neck this morning. I'll examine code now, Thanks

  5. #5
    Forum Contributor
    Join Date
    07-05-2016
    Location
    cardiff
    MS-Off Ver
    2010
    Posts
    787

    Re: Cell calculation not responding?

    All sorted. Thanks you for your help :-)

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] Not Responding
    By jaywenzel in forum Excel General
    Replies: 8
    Last Post: 08-28-2012, 07:39 PM
  2. [SOLVED] Add an amount from a calculation to a cell with a calculation (Sample attached)
    By aiwnjoo in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 04-21-2010, 10:41 AM
  3. Worksheet change event not responding to cell deletion
    By jman0707 in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 11-14-2008, 06:30 PM
  4. Worksheet change event not responding to cell deletion
    By jman0707 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 11-13-2008, 03:22 PM
  5. Macro not responding to cell deletion
    By jman0707 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 11-12-2008, 02:29 PM
  6. Worksheet_Change macro not responding to cell deletion
    By jman0707 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 11-08-2008, 09:05 PM
  7. one cell responding to data from another cell
    By cadman13 in forum Excel General
    Replies: 2
    Last Post: 02-01-2007, 12:00 PM

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