Code won't Fire

  • Thread starter Thread starter sharpie23
  • Start date Start date
S

sharpie23

This is on Sheet 6

Option Explicit

Private Sub Worsksheet_Change(ByVal Target As Range)


Call Missing

End Sub


This is in the Module

Sub Missing()


Dim StudentID
Dim StudentRow As Integer
Dim StudentRange As Range

StudentID = Worksheets(6).Range("C7").Value
On Error GoTo JFK
StudentRow = Application.WorksheetFunction.Match(StudentID,
Worksheets(2).Range("C:C"), 0)
Set StudentRange = Worksheets(2).Cells(StudentRow, 4)
Set StudentRange = StudentRange.Resize(1, 60)
'StudentRange.CurrentRegion.Columns.Count - 1)
Application.EnableEvents = False
Worksheets(6).Range("A11:A500").ClearContents
Application.EnableEvents = True
s = 11
For Each c In StudentRange.Cells
If c = 0 Then
Application.EnableEvents = False
Worksheets(6).Cells(s, 1) = c.Offset(5 - StudentRow,
0).Value
s = s + 1
Application.EnableEvents = True
End If
Next

Exit Sub

JFK:
Application.EnableEvents = False
Worksheets(6).Range("A11:A500").ClearContents
Worksheets(6).Cells(11, 1) = "Wrong ID Number"
Application.EnableEvents = True


End Sub

No matter What I do to the Sheet it will not fire the code. I can get
it to start by assinging it a button to push on the main page, but
otherwise it will not work.

Any ideas?
 
The first thing I would check is to ensure that EnableEvents is set to True.
It may have been set to False during testing and never got reset back to
True. In VBA, use CTRL+G to display the Immediate Window if it is not
already displayed, and enter

?Application.EnableEvents

and press Enter. If this returns False, then enter following in the
Immediate Window and press Enter:

Application.EnableEvents = True


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com
(email address is on the web site)
 
Sure you have this code on the correct WS ?
If you changing worksheet(1), but the code is on worksheet(2), then nothing
will happen.

You're not design mode are you ?

NickHK
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top