View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
Jim Thomlinson Jim Thomlinson is offline
external usenet poster
 
Posts: 5,939
Default Workbook_SheetChange won't run

The posted code should be in thisworkbook. It has reference to "sh as object"
and from the description it should run on any change to any sheet.
--
HTH...

Jim Thomlinson


"Don Guillett" wrote:

Try putting in the worksheet_change event in the SHEET module

--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"XL Novice DD..." <XL Novice wrote in
message ...
My understanding of Workbook_SheetChange is that with ANY change ANYWHERE
in
the workbook, the code runs, correct? I can't get it to work and don't
know
why:

GOAL: Resort the "PatientNamesRooms" (just a list of about 60 names and
associated hospital room numbers) whenever a change is made on a different
tab within the workbook. Cells in "PatientNamesRooms" are index formulas
that get names based on room numbers from a main roster of names. We need
to
quickly find the name alphabetically to determine what room they're in.

I've gotten the code to run (names to sort) using Worksheet
SelectionChange.
But that doesn't meet my need. It needs to resort anytime someone updates
a
name in the roster (like when a patient leaves or is admitted on the
floor).

CODE THAT WON'T RUN:
Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Source As
Range)
Range("PatientNamesRooms").Select Selection.Sort Key1:=Range("A1"),
Order1:=xlAscending, Header:=xlGuess, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom,
DataOption1:=xlSortNormal

End Sub

Help?