Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 791
Default sort excel when the workbook is opened

Hi, could anyone tell me how to automatically sort a worksheet when the
workbook is opened please?
ie I have data in column A in sheet1 on workbook1 that is linked to
workbook2. When I open workbook1 the data in workbook2 may have been changed
and I want to sort the data in column A, workbook1 without having to click
sort.
Thank you in anticipation.
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 3,101
Default sort excel when the workbook is opened

This will sort column A on sheet 1 every time the workbook is opened. You
will have to change the worksheet name and maybe ascendind/descending

Private Sub Workbook_Open()
Worksheets("Sheet1").Select
Cells.Select
Selection.Sort Key1:=Range("A1"), Order1:=xlAscending
End Sub

Mike
"Michael" wrote:

Hi, could anyone tell me how to automatically sort a worksheet when the
workbook is opened please?
ie I have data in column A in sheet1 on workbook1 that is linked to
workbook2. When I open workbook1 the data in workbook2 may have been changed
and I want to sort the data in column A, workbook1 without having to click
sort.
Thank you in anticipation.

  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 791
Default sort excel when the workbook is opened

Thanks, I have pasted that code by clicking view code on sheet1 of my
worksheet and then pasting the code you gave me and it works if I select the
macro and run it but I want it to be sorted automatically without having to
press anything. Have I done something wrong?

"Mike" wrote:

This will sort column A on sheet 1 every time the workbook is opened. You
will have to change the worksheet name and maybe ascendind/descending

Private Sub Workbook_Open()
Worksheets("Sheet1").Select
Cells.Select
Selection.Sort Key1:=Range("A1"), Order1:=xlAscending
End Sub

Mike
"Michael" wrote:

Hi, could anyone tell me how to automatically sort a worksheet when the
workbook is opened please?
ie I have data in column A in sheet1 on workbook1 that is linked to
workbook2. When I open workbook1 the data in workbook2 may have been changed
and I want to sort the data in column A, workbook1 without having to click
sort.
Thank you in anticipation.

  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 3,101
Default sort excel when the workbook is opened

Michael,

You've put the code in the wrong place. Do this.
open workbook and click TOOLS - MACRO - VISUAL BASIC EDITOR
Double click THIS WORKBOOK
In the drop down select WORKBOOK
In the other dropdown (If it doesn't come up automatically) Select OPEN
Paste the code in there and save. The first and last lines are created
automatically so be careful to only paste the middle 3 lines.

Mike


"Michael" wrote:

Thanks, I have pasted that code by clicking view code on sheet1 of my
worksheet and then pasting the code you gave me and it works if I select the
macro and run it but I want it to be sorted automatically without having to
press anything. Have I done something wrong?

"Mike" wrote:

This will sort column A on sheet 1 every time the workbook is opened. You
will have to change the worksheet name and maybe ascendind/descending

Private Sub Workbook_Open()
Worksheets("Sheet1").Select
Cells.Select
Selection.Sort Key1:=Range("A1"), Order1:=xlAscending
End Sub

Mike
"Michael" wrote:

Hi, could anyone tell me how to automatically sort a worksheet when the
workbook is opened please?
ie I have data in column A in sheet1 on workbook1 that is linked to
workbook2. When I open workbook1 the data in workbook2 may have been changed
and I want to sort the data in column A, workbook1 without having to click
sort.
Thank you in anticipation.

  #5   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 791
Default sort excel when the workbook is opened

Excellent, although I had to paste all 5 lines for it to work. Thank you very
much

"Mike" wrote:

Michael,

You've put the code in the wrong place. Do this.
open workbook and click TOOLS - MACRO - VISUAL BASIC EDITOR
Double click THIS WORKBOOK
In the drop down select WORKBOOK
In the other dropdown (If it doesn't come up automatically) Select OPEN
Paste the code in there and save. The first and last lines are created
automatically so be careful to only paste the middle 3 lines.

Mike


"Michael" wrote:

Thanks, I have pasted that code by clicking view code on sheet1 of my
worksheet and then pasting the code you gave me and it works if I select the
macro and run it but I want it to be sorted automatically without having to
press anything. Have I done something wrong?

"Mike" wrote:

This will sort column A on sheet 1 every time the workbook is opened. You
will have to change the worksheet name and maybe ascendind/descending

Private Sub Workbook_Open()
Worksheets("Sheet1").Select
Cells.Select
Selection.Sort Key1:=Range("A1"), Order1:=xlAscending
End Sub

Mike
"Michael" wrote:

Hi, could anyone tell me how to automatically sort a worksheet when the
workbook is opened please?
ie I have data in column A in sheet1 on workbook1 that is linked to
workbook2. When I open workbook1 the data in workbook2 may have been changed
and I want to sort the data in column A, workbook1 without having to click
sort.
Thank you in anticipation.



  #6   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 7
Default sort excel when the workbook is opened

This code work great, but let me ask how to accomplish this to exclude the
header row, 1?

Thanks, Bill

"Michael" wrote:

Excellent, although I had to paste all 5 lines for it to work. Thank you very
much

"Mike" wrote:

Michael,

You've put the code in the wrong place. Do this.
open workbook and click TOOLS - MACRO - VISUAL BASIC EDITOR
Double click THIS WORKBOOK
In the drop down select WORKBOOK
In the other dropdown (If it doesn't come up automatically) Select OPEN
Paste the code in there and save. The first and last lines are created
automatically so be careful to only paste the middle 3 lines.

Mike


"Michael" wrote:

Thanks, I have pasted that code by clicking view code on sheet1 of my
worksheet and then pasting the code you gave me and it works if I select the
macro and run it but I want it to be sorted automatically without having to
press anything. Have I done something wrong?

"Mike" wrote:

This will sort column A on sheet 1 every time the workbook is opened. You
will have to change the worksheet name and maybe ascendind/descending

Private Sub Workbook_Open()
Worksheets("Sheet1").Select
Cells.Select
Selection.Sort Key1:=Range("A1"), Order1:=xlAscending
End Sub

Mike
"Michael" wrote:

Hi, could anyone tell me how to automatically sort a worksheet when the
workbook is opened please?
ie I have data in column A in sheet1 on workbook1 that is linked to
workbook2. When I open workbook1 the data in workbook2 may have been changed
and I want to sort the data in column A, workbook1 without having to click
sort.
Thank you in anticipation.

  #7   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 35,218
Default sort excel when the workbook is opened

So row 1 is the header?

Selection.Sort Key1:=Range("A1"), Order1:=xlAscending, header:=xlyes



Bilbert wrote:

This code work great, but let me ask how to accomplish this to exclude the
header row, 1?

Thanks, Bill

"Michael" wrote:

Excellent, although I had to paste all 5 lines for it to work. Thank you very
much

"Mike" wrote:

Michael,

You've put the code in the wrong place. Do this.
open workbook and click TOOLS - MACRO - VISUAL BASIC EDITOR
Double click THIS WORKBOOK
In the drop down select WORKBOOK
In the other dropdown (If it doesn't come up automatically) Select OPEN
Paste the code in there and save. The first and last lines are created
automatically so be careful to only paste the middle 3 lines.

Mike


"Michael" wrote:

Thanks, I have pasted that code by clicking view code on sheet1 of my
worksheet and then pasting the code you gave me and it works if I select the
macro and run it but I want it to be sorted automatically without having to
press anything. Have I done something wrong?

"Mike" wrote:

This will sort column A on sheet 1 every time the workbook is opened. You
will have to change the worksheet name and maybe ascendind/descending

Private Sub Workbook_Open()
Worksheets("Sheet1").Select
Cells.Select
Selection.Sort Key1:=Range("A1"), Order1:=xlAscending
End Sub

Mike
"Michael" wrote:

Hi, could anyone tell me how to automatically sort a worksheet when the
workbook is opened please?
ie I have data in column A in sheet1 on workbook1 that is linked to
workbook2. When I open workbook1 the data in workbook2 may have been changed
and I want to sort the data in column A, workbook1 without having to click
sort.
Thank you in anticipation.


--

Dave Peterson
  #8   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 7
Default sort excel when the workbook is opened

Beautiful, thanks! Bill

"Dave Peterson" wrote:

So row 1 is the header?

Selection.Sort Key1:=Range("A1"), Order1:=xlAscending, header:=xlyes



Bilbert wrote:

This code work great, but let me ask how to accomplish this to exclude the
header row, 1?

Thanks, Bill

"Michael" wrote:

Excellent, although I had to paste all 5 lines for it to work. Thank you very
much

"Mike" wrote:

Michael,

You've put the code in the wrong place. Do this.
open workbook and click TOOLS - MACRO - VISUAL BASIC EDITOR
Double click THIS WORKBOOK
In the drop down select WORKBOOK
In the other dropdown (If it doesn't come up automatically) Select OPEN
Paste the code in there and save. The first and last lines are created
automatically so be careful to only paste the middle 3 lines.

Mike


"Michael" wrote:

Thanks, I have pasted that code by clicking view code on sheet1 of my
worksheet and then pasting the code you gave me and it works if I select the
macro and run it but I want it to be sorted automatically without having to
press anything. Have I done something wrong?

"Mike" wrote:

This will sort column A on sheet 1 every time the workbook is opened. You
will have to change the worksheet name and maybe ascendind/descending

Private Sub Workbook_Open()
Worksheets("Sheet1").Select
Cells.Select
Selection.Sort Key1:=Range("A1"), Order1:=xlAscending
End Sub

Mike
"Michael" wrote:

Hi, could anyone tell me how to automatically sort a worksheet when the
workbook is opened please?
ie I have data in column A in sheet1 on workbook1 that is linked to
workbook2. When I open workbook1 the data in workbook2 may have been changed
and I want to sort the data in column A, workbook1 without having to click
sort.
Thank you in anticipation.


--

Dave Peterson

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 VBA Merge Workbook tables Central table [email protected] Excel Discussion (Misc queries) 1 January 15th 06 03:16 PM
Data from Excel 2000 Worksheet with external links is not displayed when opened in Excel 2003 Rich Rodberg Links and Linking in Excel 1 October 21st 05 07:53 AM
How do I sort letters before numbers in Excel? RiverGirl Excel Discussion (Misc queries) 4 May 27th 05 04:09 PM
Can a workbook be opened w/out Excel on the host machine?? MIchelleDuquette Excel Discussion (Misc queries) 2 May 5th 05 08:18 PM
Stubborn toolbars in Excel 007 Excel Discussion (Misc queries) 9 December 11th 04 02:02 PM


All times are GMT +1. The time now is 11:14 PM.

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"