Notices
Computer & Technology Related Post here for help and discussion of computing and related technology. Internet, TVs, phones, consoles, computers, tablets and any other gadgets.

Excel Macro

Thread Tools
 
Search this Thread
 
Old Dec 11, 2006 | 05:36 PM
  #1  
SiGill's Avatar
SiGill
Thread Starter
Scooby Newbie
 
Joined: Nov 2006
Posts: 6
Likes: 0
Default Excel Macro

Hi

I have the following in an excel spreadsheet which sorts a range of cells I have but after its sorted the cells it highlights all the cells and leaves me in the last cell, I can't move anywhere, what can i do to change this.

I Have:

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Range("B26:J35").Select
Range("J35").Activate
Selection.Sort Key1:=Range("J26"), Order1:=xlDescending
End Sub

Any help is appreciated.
Reply
Old Dec 11, 2006 | 06:59 PM
  #2  
HankScorpio's Avatar
HankScorpio
Scooby Regular
 
Joined: Feb 2004
Posts: 5,848
Likes: 0
Default

Stick this at the end (to select A1)

Range("A1").Select
Reply
Old Dec 12, 2006 | 09:55 AM
  #3  
SiGill's Avatar
SiGill
Thread Starter
Scooby Newbie
 
Joined: Nov 2006
Posts: 6
Likes: 0
Default

Thanks for the reply but this didn't work. It just started to select each cell in turn at speed then come up with a debug screen.

Any other ideas?
Reply
Old Dec 13, 2006 | 01:32 PM
  #4  
michaelro's Avatar
michaelro
Scooby Regular
 
Joined: Jan 2006
Posts: 897
Likes: 0
Default

Looks like it's getting stuck in a loop.

Worksheet_SelectionChange will run everytime the cell changes.

I would expect you need the macro to run everytime you update the worksheet rather than move between cells?

If so this should work:

Private Sub Worksheet_Change(ByVal Target As Range)
Range("B26:J35").Select
Range("J35").Activate
Selection.Sort Key1:=Range("J26"), Order1:=xlDescending
End Sub

Delete the old macro or that will take priority.
Reply
Related Topics
Thread
Thread Starter
Forum
Replies
Last Post
Mattybr5@MB Developments
Full Cars Breaking For Spares
28
Dec 28, 2015 11:07 PM
Mattybr5@MB Developments
Full Cars Breaking For Spares
12
Nov 18, 2015 07:03 AM
leg200
Subaru Parts
5
Oct 7, 2015 07:31 AM
has-scooby
Subaru Parts
4
Oct 6, 2015 03:47 PM
bluebullet29
General Technical
9
Oct 5, 2015 02:17 PM




All times are GMT +1. The time now is 04:32 AM.