Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default code doesnt work

It all depends upon what you want to trigger the check. If it is to be data
in the Tracking sheet, C4:C100, then it should be

Private Sub Worksheet_Change(ByVal Target As Range)
Dim ans
If Target.Address = "C4:100" Then
If WorksheetFunction.CountIf(Range("C4:C100"), Range("Sale!P2"))
0 Then
ans = MsgBox("Continue", vbYesNo)
If ans = vbYes Then Application.Run (SortTracker)
End If
End If

End Sub

If it is to be a change to P2 on tghe Sale sheet it should be


Private Sub Worksheet_Change(ByVal Target As Range)
Dim ans
If Target.Address = "$P$2" Then
If WorksheetFunction.CountIf(Range("Tracking!C4:C100" ),
Range("P2")) 0 Then
ans = MsgBox("Continue", vbYesNo)
If ans = vbYes Then Application.Run (SortTracker)
End If
End If

End Sub


You cannot have a cell on one sheet triggering an event on another. And you
must put it in the worksheet nmodule.
--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"Choice" wrote in message
...
Still not working, this is exactly what i have in there. when i go to

Sale!P2...type in a number nothing happens

Private Sub Worksheet_Change(ByVal Target As Range)
Dim ans
If Target.Address = "sale!$P$2" Then
If WorksheetFunction.CountIf(Range("Tracking!C4:C100" ),

Range("Sale!P2")) 0 Then

ans = MsgBox("Continue", vbYesNo)
If ans = vbYes Then Application.Run (SortTracker)
End If
End If

End Sub



  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 18
Default code doesnt work

when i type a number into sale!p2 and hit enter, i want it to check to see if that number is in tracking!C4:C1000. if its not then i want the message to come up
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default code doesnt work

This should work


Private Sub Worksheet_Change(ByVal Target As Range)
Dim ans
If Target.Address = "$P$2" Then
If WorksheetFunction.CountIf(Worksheets("Tracking"). _
Range("C4:C100"), Range("P2").Value) 0 Then
ans = MsgBox("Continue", vbYesNo)
If ans = vbYes Then SortTracker
End If
End If

End Sub

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"choice" wrote in message
...
when i type a number into sale!p2 and hit enter, i want it to check to see

if that number is in tracking!C4:C1000. if its not then i want the message
to come up


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Why doesnt this work? MurrayBarn Excel Worksheet Functions 2 November 19th 09 04:21 PM
Why doesnt shortcut key work on some but not on others? Craig Excel Discussion (Misc queries) 3 August 12th 08 03:20 PM
Why doesnt this work steve New Users to Excel 1 March 3rd 08 04:52 PM
code doesnt work Juan Pablo Gonzalez Excel Programming 1 April 23rd 04 09:51 PM
code doesnt work Juan Pablo Gonzalez Excel Programming 0 April 23rd 04 09:19 PM


All times are GMT +1. The time now is 11:10 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"