![]() |
Button Problem with the Sort command
Hope this takes this time.
I have on sheet 1 a button that I have attached code to that is suppose to sort data on sheet 2, sheet 3, sheet 4, well it is not working. So I'm asking for help in trying to figure out what I'm doing wrong. On sheet 1 the code is: Private Sub Main Button 1() Sheets ("Sheet 1").Select ActiveSheet.Range ("A1:D45").Select Call Sort1 Sheets ("Sheet 2").Select ActiveSheet.Range ("A1:D45").Select Call Sort1 Sheets ("Sheet 3").Select ActiveSheet.Range ("A1:D45").Select Call Sort1 End Sub ================= Private Sub Sort1() Selection.Sort Key1:=Range("B1"), Order1:=xlAscending, Header:=xlNo, OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, DataOption1:=xlSortNormal End Sub ================= |
Button Problem with the Sort command
Sorry met to let you folks know that I'm working in Excel 2003
"michdenis" wrote: Hi, Your code should be working fine ! I suppose you have a Excel 1997 version and the button you are using to trigger your macro comes from the control tool bar. If my guest is right, in creation mode, modify the property "TakeFocusOnClic" of the button to False. This is a well known bug. "caldog" a écrit dans le message de groupe de discussion : ... Hope this takes this time. I have on sheet 1 a button that I have attached code to that is suppose to sort data on sheet 2, sheet 3, sheet 4, well it is not working. So I'm asking for help in trying to figure out what I'm doing wrong. On sheet 1 the code is: Private Sub Main Button 1() Sheets ("Sheet 1").Select ActiveSheet.Range ("A1:D45").Select Call Sort1 Sheets ("Sheet 2").Select ActiveSheet.Range ("A1:D45").Select Call Sort1 Sheets ("Sheet 3").Select ActiveSheet.Range ("A1:D45").Select Call Sort1 End Sub ================= Private Sub Sort1() Selection.Sort Key1:=Range("B1"), Order1:=xlAscending, Header:=xlNo, OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, DataOption1:=xlSortNormal End Sub ================= |
Button Problem with the Sort command
Your code is working with Excel 2007.
Did you put your code in a general module ? "caldog" a écrit dans le message de groupe de discussion : ... Sorry met to let you folks know that I'm working in Excel 2003 "michdenis" wrote: Hi, Your code should be working fine ! I suppose you have a Excel 1997 version and the button you are using to trigger your macro comes from the control tool bar. If my guest is right, in creation mode, modify the property "TakeFocusOnClic" of the button to False. This is a well known bug. "caldog" a écrit dans le message de groupe de discussion : ... Hope this takes this time. I have on sheet 1 a button that I have attached code to that is suppose to sort data on sheet 2, sheet 3, sheet 4, well it is not working. So I'm asking for help in trying to figure out what I'm doing wrong. On sheet 1 the code is: Private Sub Main Button 1() Sheets ("Sheet 1").Select ActiveSheet.Range ("A1:D45").Select Call Sort1 Sheets ("Sheet 2").Select ActiveSheet.Range ("A1:D45").Select Call Sort1 Sheets ("Sheet 3").Select ActiveSheet.Range ("A1:D45").Select Call Sort1 End Sub ================= Private Sub Sort1() Selection.Sort Key1:=Range("B1"), Order1:=xlAscending, Header:=xlNo, OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, DataOption1:=xlSortNormal End Sub ================= |
Button Problem with the Sort command
I beleive that I'm. I use the macro recorder, then assign the code generated
to the button. This is my process when I'm attaching code to a button. The error message that I'm getting is: The sort reference is not valid. Make sure that it's within the data you want to sort, and the Sort By box isn't the same or blank" "michdenis" wrote: Your code is working with Excel 2007. Did you put your code in a general module ? "caldog" a écrit dans le message de groupe de discussion : ... Sorry met to let you folks know that I'm working in Excel 2003 "michdenis" wrote: Hi, Your code should be working fine ! I suppose you have a Excel 1997 version and the button you are using to trigger your macro comes from the control tool bar. If my guest is right, in creation mode, modify the property "TakeFocusOnClic" of the button to False. This is a well known bug. "caldog" a écrit dans le message de groupe de discussion : ... Hope this takes this time. I have on sheet 1 a button that I have attached code to that is suppose to sort data on sheet 2, sheet 3, sheet 4, well it is not working. So I'm asking for help in trying to figure out what I'm doing wrong. On sheet 1 the code is: Private Sub Main Button 1() Sheets ("Sheet 1").Select ActiveSheet.Range ("A1:D45").Select Call Sort1 Sheets ("Sheet 2").Select ActiveSheet.Range ("A1:D45").Select Call Sort1 Sheets ("Sheet 3").Select ActiveSheet.Range ("A1:D45").Select Call Sort1 End Sub ================= Private Sub Sort1() Selection.Sort Key1:=Range("B1"), Order1:=xlAscending, Header:=xlNo, OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, DataOption1:=xlSortNormal End Sub ================= |
Button Problem with the Sort command
an example : http://cjoint.com/?bmfrwVxLkB
"caldog" a écrit dans le message de groupe de discussion : ... I beleive that I'm. I use the macro recorder, then assign the code generated to the button. This is my process when I'm attaching code to a button. The error message that I'm getting is: The sort reference is not valid. Make sure that it's within the data you want to sort, and the Sort By box isn't the same or blank" "michdenis" wrote: Your code is working with Excel 2007. Did you put your code in a general module ? "caldog" a écrit dans le message de groupe de discussion : ... Sorry met to let you folks know that I'm working in Excel 2003 "michdenis" wrote: Hi, Your code should be working fine ! I suppose you have a Excel 1997 version and the button you are using to trigger your macro comes from the control tool bar. If my guest is right, in creation mode, modify the property "TakeFocusOnClic" of the button to False. This is a well known bug. "caldog" a écrit dans le message de groupe de discussion : ... Hope this takes this time. I have on sheet 1 a button that I have attached code to that is suppose to sort data on sheet 2, sheet 3, sheet 4, well it is not working. So I'm asking for help in trying to figure out what I'm doing wrong. On sheet 1 the code is: Private Sub Main Button 1() Sheets ("Sheet 1").Select ActiveSheet.Range ("A1:D45").Select Call Sort1 Sheets ("Sheet 2").Select ActiveSheet.Range ("A1:D45").Select Call Sort1 Sheets ("Sheet 3").Select ActiveSheet.Range ("A1:D45").Select Call Sort1 End Sub ================= Private Sub Sort1() Selection.Sort Key1:=Range("B1"), Order1:=xlAscending, Header:=xlNo, OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, DataOption1:=xlSortNormal End Sub ================= |
Button Problem with the Sort command
How did you attach that worksheet? An I will attach mine so that you can see
what I'm trying to do. Yours is slightly different then mine. "michdenis" wrote: an example : http://cjoint.com/?bmfrwVxLkB "caldog" a écrit dans le message de groupe de discussion : ... I beleive that I'm. I use the macro recorder, then assign the code generated to the button. This is my process when I'm attaching code to a button. The error message that I'm getting is: The sort reference is not valid. Make sure that it's within the data you want to sort, and the Sort By box isn't the same or blank" "michdenis" wrote: Your code is working with Excel 2007. Did you put your code in a general module ? "caldog" a écrit dans le message de groupe de discussion : ... Sorry met to let you folks know that I'm working in Excel 2003 "michdenis" wrote: Hi, Your code should be working fine ! I suppose you have a Excel 1997 version and the button you are using to trigger your macro comes from the control tool bar. If my guest is right, in creation mode, modify the property "TakeFocusOnClic" of the button to False. This is a well known bug. "caldog" a écrit dans le message de groupe de discussion : ... Hope this takes this time. I have on sheet 1 a button that I have attached code to that is suppose to sort data on sheet 2, sheet 3, sheet 4, well it is not working. So I'm asking for help in trying to figure out what I'm doing wrong. On sheet 1 the code is: Private Sub Main Button 1() Sheets ("Sheet 1").Select ActiveSheet.Range ("A1:D45").Select Call Sort1 Sheets ("Sheet 2").Select ActiveSheet.Range ("A1:D45").Select Call Sort1 Sheets ("Sheet 3").Select ActiveSheet.Range ("A1:D45").Select Call Sort1 End Sub ================= Private Sub Sort1() Selection.Sort Key1:=Range("B1"), Order1:=xlAscending, Header:=xlNo, OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, DataOption1:=xlSortNormal End Sub ================= |
Button Problem with the Sort command
I finally got it to work. I was not putting it in the module 'section' I was putting it into my general coding page. When I transfered it, it work just fine. Thanks a whole lot, for your help. "caldog" wrote: How did you attach that worksheet? An I will attach mine so that you can see what I'm trying to do. Yours is slightly different then mine. "michdenis" wrote: an example : http://cjoint.com/?bmfrwVxLkB "caldog" a écrit dans le message de groupe de discussion : ... I beleive that I'm. I use the macro recorder, then assign the code generated to the button. This is my process when I'm attaching code to a button. The error message that I'm getting is: The sort reference is not valid. Make sure that it's within the data you want to sort, and the Sort By box isn't the same or blank" "michdenis" wrote: Your code is working with Excel 2007. Did you put your code in a general module ? "caldog" a écrit dans le message de groupe de discussion : ... Sorry met to let you folks know that I'm working in Excel 2003 "michdenis" wrote: Hi, Your code should be working fine ! I suppose you have a Excel 1997 version and the button you are using to trigger your macro comes from the control tool bar. If my guest is right, in creation mode, modify the property "TakeFocusOnClic" of the button to False. This is a well known bug. "caldog" a écrit dans le message de groupe de discussion : ... Hope this takes this time. I have on sheet 1 a button that I have attached code to that is suppose to sort data on sheet 2, sheet 3, sheet 4, well it is not working. So I'm asking for help in trying to figure out what I'm doing wrong. On sheet 1 the code is: Private Sub Main Button 1() Sheets ("Sheet 1").Select ActiveSheet.Range ("A1:D45").Select Call Sort1 Sheets ("Sheet 2").Select ActiveSheet.Range ("A1:D45").Select Call Sort1 Sheets ("Sheet 3").Select ActiveSheet.Range ("A1:D45").Select Call Sort1 End Sub ================= Private Sub Sort1() Selection.Sort Key1:=Range("B1"), Order1:=xlAscending, Header:=xlNo, OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, DataOption1:=xlSortNormal End Sub ================= |
All times are GMT +1. The time now is 01:23 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com