Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
"Sort" macro in late bound code
I'm having trouble converting a macro to late bound code so I can run it in
Access. I recorded the macro in Excel and got the following code Columns("A:C").Select Selection.Sort Key1:=Range("C2"), Order1:=xlDescending, Header:=xlGuess, _ OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom So far, I've been able to get rid of the xl... references by converting them to their equivalent numbers and have the following code ..Columns("A:C").Select ..Selection.Sort Key1:=Range("C2"), Order1:=2, Header:=1, _ OrderCustom:=1, MatchCase:=False, Orientation:=1 The problem I have is that when the code runs, Range is highlighted with the error Sub or Function not defined. What do I need to replace this with? Ian |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
"Sort" macro in late bound code
This worked for me. Sorted on col C.
Sub srtcol() Columns("A:C").Sort Key1:=Range("C2"), Order1:=2, Header:=1, _ OrderCustom:=1, MatchCase:=False, Orientation:=1 End Sub "Ian" wrote: I'm having trouble converting a macro to late bound code so I can run it in Access. I recorded the macro in Excel and got the following code Columns("A:C").Select Selection.Sort Key1:=Range("C2"), Order1:=xlDescending, Header:=xlGuess, _ OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom So far, I've been able to get rid of the xl... references by converting them to their equivalent numbers and have the following code ..Columns("A:C").Select ..Selection.Sort Key1:=Range("C2"), Order1:=2, Header:=1, _ OrderCustom:=1, MatchCase:=False, Orientation:=1 The problem I have is that when the code runs, Range is highlighted with the error Sub or Function not defined. What do I need to replace this with? Ian |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
"Sort" macro in late bound code
It works perfectly in when run in Excel VBA, but not when the code is in
Access VBA. It still says "Sub or Function not defined" relating to Range. Any other thoughts? Ian "JLGWhiz" wrote in message ... This worked for me. Sorted on col C. Sub srtcol() Columns("A:C").Sort Key1:=Range("C2"), Order1:=2, Header:=1, _ OrderCustom:=1, MatchCase:=False, Orientation:=1 End Sub "Ian" wrote: I'm having trouble converting a macro to late bound code so I can run it in Access. I recorded the macro in Excel and got the following code Columns("A:C").Select Selection.Sort Key1:=Range("C2"), Order1:=xlDescending, Header:=xlGuess, _ OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom So far, I've been able to get rid of the xl... references by converting them to their equivalent numbers and have the following code ..Columns("A:C").Select ..Selection.Sort Key1:=Range("C2"), Order1:=2, Header:=1, _ OrderCustom:=1, MatchCase:=False, Orientation:=1 The problem I have is that when the code runs, Range is highlighted with the error Sub or Function not defined. What do I need to replace this with? Ian |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
"Sort" macro in late bound code
Got it!
Access didn't know what the range referred to. I changed Range with objExcel.Range and it works like a dream. Ian "Ian" wrote in message ... It works perfectly in when run in Excel VBA, but not when the code is in Access VBA. It still says "Sub or Function not defined" relating to Range. Any other thoughts? Ian "JLGWhiz" wrote in message ... This worked for me. Sorted on col C. Sub srtcol() Columns("A:C").Sort Key1:=Range("C2"), Order1:=2, Header:=1, _ OrderCustom:=1, MatchCase:=False, Orientation:=1 End Sub "Ian" wrote: I'm having trouble converting a macro to late bound code so I can run it in Access. I recorded the macro in Excel and got the following code Columns("A:C").Select Selection.Sort Key1:=Range("C2"), Order1:=xlDescending, Header:=xlGuess, _ OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom So far, I've been able to get rid of the xl... references by converting them to their equivalent numbers and have the following code ..Columns("A:C").Select ..Selection.Sort Key1:=Range("C2"), Order1:=2, Header:=1, _ OrderCustom:=1, MatchCase:=False, Orientation:=1 The problem I have is that when the code runs, Range is highlighted with the error Sub or Function not defined. What do I need to replace this with? Ian |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Missing sort ascending or descending when go into "data" "sort"? | Excel Discussion (Misc queries) | |||
Read ".dll" files, the Macro "work flow" and the actual values of the variables when Macro is running | Excel Programming | |||
pictures to work with "data" "sort" option | Excel Discussion (Misc queries) | |||
can I sort using column headings, in a macro, not "a1" | Excel Programming | |||
Looking for VB code to test for "RING" , "BUSY" disconnects or other signals | Excel Programming |