Try:
If Not Intersect(Target, Range("B:B")) Is Nothing Then
Range("A:B").Sort Key1:=Range("A1"), Order1:=xlAscending, _
Header:=xlGuess, OrderCustom:=1, _
MatchCase:=False, Orientation:=xlTopToBottom
End If
I've changed it so that it only sorts the list after you've entered the pay
rate in the second column. If I've been overly helpful (! <g), change the
If Not Intersect(Target, Range("B:B")) Is Nothing Then
to
If Not Intersect(Target, Range("A:B")) Is Nothing Then
to catch changes in both columns A and B.
--
HTH,
Dianne Butterworth
I have a 2 column range. In the the first column are job descriptions
and in the second column the pay rate for that job description.
Occasionally, I need to add a job desciption at the bottom of the list
and I want the list to sort itself after I enter the new job
description. I also want the pay rates to sort with the job
descriptions at the same time. Below is the code I'm using. When I
type a new job description and hit ENTER the following error shows.
Run-time error '1004':
Application-defined or Object-defined error
Option Explicit
Private Sub Worksheet_Change(ByVal Target As Range)
Columns(1, 2).Sort Key1:=Range("A1"), Order1:=xlAscending, _
Header:=xlGuess, OrderCustom:=1, _
MatchCase:=False, Orientation:=xlTopToBottom
End Sub
Many thanks
Casey
---
Message posted from http://www.ExcelForum.com/