Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 85
Default "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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,986
Default "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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 85
Default "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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 85
Default "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
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
Missing sort ascending or descending when go into "data" "sort"? Jason Excel Discussion (Misc queries) 5 September 17th 08 11:57 PM
Read ".dll" files, the Macro "work flow" and the actual values of the variables when Macro is running [email protected] Excel Programming 5 May 16th 07 08:18 PM
pictures to work with "data" "sort" option arad Excel Discussion (Misc queries) 1 April 18th 06 09:15 PM
can I sort using column headings, in a macro, not "a1" John Excel Programming 4 October 23rd 04 05:02 PM
Looking for VB code to test for "RING" , "BUSY" disconnects or other signals BruceJ[_2_] Excel Programming 3 November 20th 03 01:55 AM


All times are GMT +1. The time now is 04: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"