View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
richardg richardg is offline
external usenet poster
 
Posts: 4
Default Chabnging macros to functions

I have the following macro to sort a range of cells :-
Range("A2:J5").Select
Range("J2").Activate
Selection.Sort Key1:=Range("J2"), Key2:=Range("I2"), Key3:=Range("G2"),
Order1:=xlDescending, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom

That works fine when attahced to a button, bit I wanted it to work
automatically when I update a second sheet that drives formulas on the
original sheet.
I'm using the "Private Sub worksheet_Calculate()" event to drive it, but
using the same code as above gives me a Range selection error.
Anyone any ideas how to get round this?