View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Casey[_10_] Casey[_10_] is offline
external usenet poster
 
Posts: 1
Default Sorting a 2 column list with VBA using Worksheet change produces 1004 error

I have a 2 column range. In the the first column are job description
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 lis
and I want the list to sort itself after I enter the new jo
description. I also want the pay rates to sort with the jo
descriptions at the same time. Below is the code I'm using. When I typ
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
Case

--
Message posted from http://www.ExcelForum.com