Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.misc
|
|||
|
|||
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
Posted to microsoft.public.excel.misc
|
|||
|
|||
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
Posted to microsoft.public.excel.misc
|
|||
|
|||
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
Posted to microsoft.public.excel.misc
|
|||
|
|||
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
Posted to microsoft.public.excel.misc
|
|||
|
|||
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
Posted to microsoft.public.excel.misc
|
|||
|
|||
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
Posted to microsoft.public.excel.misc
|
|||
|
|||
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
Posted to microsoft.public.excel.misc
|
|||
|
|||
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 |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Excel VBA Merge Workbook tables Central table | Excel Discussion (Misc queries) | |||
Data from Excel 2000 Worksheet with external links is not displayed when opened in Excel 2003 | Links and Linking in Excel | |||
How do I sort letters before numbers in Excel? | Excel Discussion (Misc queries) | |||
Can a workbook be opened w/out Excel on the host machine?? | Excel Discussion (Misc queries) | |||
Stubborn toolbars in Excel | Excel Discussion (Misc queries) |