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 11 December 2006, 05:36 PM
  #1  
SiGill
Scooby Newbie
Thread Starter
 
SiGill's Avatar
 
Join Date: Nov 2006
Posts: 6
Likes: 0
Received 0 Likes on 0 Posts
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.
Old 11 December 2006, 06:59 PM
  #2  
HankScorpio
Scooby Regular
 
HankScorpio's Avatar
 
Join Date: Feb 2004
Posts: 5,848
Likes: 0
Received 0 Likes on 0 Posts
Default

Stick this at the end (to select A1)

Range("A1").Select
Old 12 December 2006, 09:55 AM
  #3  
SiGill
Scooby Newbie
Thread Starter
 
SiGill's Avatar
 
Join Date: Nov 2006
Posts: 6
Likes: 0
Received 0 Likes on 0 Posts
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?
Old 13 December 2006, 01:32 PM
  #4  
michaelro
Scooby Regular
 
michaelro's Avatar
 
Join Date: Jan 2006
Posts: 897
Likes: 0
Received 0 Likes on 0 Posts
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.
Related Topics
Thread
Thread Starter
Forum
Replies
Last Post
Mattybr5@MB Developments
Full Cars Breaking For Spares
28
28 December 2015 11:07 PM
Mattybr5@MB Developments
Full Cars Breaking For Spares
12
18 November 2015 07:03 AM
leg200
Subaru Parts
5
07 October 2015 07:31 AM
has-scooby
Subaru Parts
4
06 October 2015 03:47 PM
bluebullet29
General Technical
9
05 October 2015 02:17 PM



Quick Reply: Excel Macro



All times are GMT +1. The time now is 02:28 AM.