Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel,microsoft.public.excel.misc,microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default Automatic sorting in excel

I would like to be able to have a column sorted alphabetically contiuously.
In other words, whenever data is entered, the whole column gets arranged
alphabetically without having to "click' on the sort function.

I am not a power user of excel, but I now understand the basics of running a
macro. I have been guided to use the following macro example and adapt it to
my worksheet. I have tried a few changes, but I cannot get it to work. Lets
say the filename is "mybook" and the worksheet name is "sheet1" and the
range I want to sort automatically is B1:B20

Private Sub Worksheet_Change(ByVal Target As Range)


Columns("B:B").Select
Selection.Sort Key1:=Range("B1"), Order1:=xlAscending

End Sub

However, I am not sure exactly which part I need to change in this code, for
it to work on my worksheet.


Thanks.


  #2   Report Post  
Posted to microsoft.public.excel.misc,microsoft.public.excel.programming,microsoft.public.excel
external usenet poster
 
Posts: 11,058
Default Automatic sorting in excel

See:

http://www.microsoft.com/communities...1-7676c90b18d3
--
Gary's Student


"Gostal" wrote:

I would like to be able to have a column sorted alphabetically contiuously.
In other words, whenever data is entered, the whole column gets arranged
alphabetically without having to "click' on the sort function.

I am not a power user of excel, but I now understand the basics of running a
macro. I have been guided to use the following macro example and adapt it to
my worksheet. I have tried a few changes, but I cannot get it to work. Lets
say the filename is "mybook" and the worksheet name is "sheet1" and the
range I want to sort automatically is B1:B20

Private Sub Worksheet_Change(ByVal Target As Range)


Columns("B:B").Select
Selection.Sort Key1:=Range("B1"), Order1:=xlAscending

End Sub

However, I am not sure exactly which part I need to change in this code, for
it to work on my worksheet.


Thanks.



  #3   Report Post  
Posted to microsoft.public.excel.misc,microsoft.public.excel.programming,microsoft.public.excel
external usenet poster
 
Posts: 3,365
Default Automatic sorting in excel

Let's see if we can't roll all the answers up into one place. It looked to
me like, in another post, you are having trouble figuring out how to get the
code into the proper place in the Excel workbook. The code people have
pointed you to needs to go into the worksheet's code segment. Having said
that, you're probably scratching your head saying "where the #@!!? is that"?

First: here is a complete code segment that will detect a change in column B
on a sheet and sort the contents of column B, beginning with cell B1 and
continuing down to the first empty cell in that column. Changes in other
areas of the worksheet will not cause anything to happen.

Private Sub Worksheet_Change(ByVal Target As Range)
Dim whereIam As Range
Set whereIam = ActiveCell
If Intersect(Target, Range("B:B")) Is Nothing Then
Exit Sub
End If
Range("B1:" & Range("B1").End(xlDown).Address).Select
Selection.Sort Key1:=Range("B1"), Order1:=xlAscending
'and back to where you started
whereIam.Select
End Sub

Second: Copy that code and open your workbook and select the sheet that it
needs to work with. Right-Click on the worksheet's name tab and choose View
Code from the list. Paste all of the code right into the area that shows up.
Close that window and then take it for a test drive.

"Gostal" wrote:

I would like to be able to have a column sorted alphabetically contiuously.
In other words, whenever data is entered, the whole column gets arranged
alphabetically without having to "click' on the sort function.

I am not a power user of excel, but I now understand the basics of running a
macro. I have been guided to use the following macro example and adapt it to
my worksheet. I have tried a few changes, but I cannot get it to work. Lets
say the filename is "mybook" and the worksheet name is "sheet1" and the
range I want to sort automatically is B1:B20

Private Sub Worksheet_Change(ByVal Target As Range)


Columns("B:B").Select
Selection.Sort Key1:=Range("B1"), Order1:=xlAscending

End Sub

However, I am not sure exactly which part I need to change in this code, for
it to work on my worksheet.


Thanks.



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Excel 2003 FAILS, but Excel 2000 SUCCEEDS ??? Richard Excel Discussion (Misc queries) 2 May 13th 23 11:46 AM
How do I remove the annoying automatic date formatting in Excel? Jose-Edinburgh Excel Discussion (Misc queries) 2 May 10th 23 11:43 AM
Excel Date Format - users should be able to override it automatic. jamezog Excel Discussion (Misc queries) 7 May 20th 10 02:45 PM
Multiple Excel versions. Naveen Mukkelli Excel Discussion (Misc queries) 0 May 16th 06 12:55 AM
Excel: Allow to turn on / off automatic header selection in sorts GentleScot Excel Discussion (Misc queries) 0 August 28th 05 06:39 PM


All times are GMT +1. The time now is 01:44 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"