Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Sort columns in Excel using VBA

Status
Not open for further replies.
Jan 22, 2001
124
US
Hi

This is the code I'm using to find the number of columns that need sorted. The cells contain date data (ex. Jun - 2002).

Do
.ActiveCell.Offset(0, 1).Activate
testcounter = testcounter + 1
Loop Until IsEmpty(.ActiveCell)
testcounter = testcounter - 1

Below is the code I'm attempting to use to sort the data. This code was created by a macro in Excel. Can anyone tell me how to change it so that Access can read it? I realize the constants "xlAscending", "xlGuess", and "xlLeftToRight" will have to be replaced with "1", "0", and "2" respectively.

Columns("B:H").Select
Selection.Sort Key1:=Range("B1"), Order1:=xlAscending, Header:=xlGuess, OrderCustom:=4, MatchCase:=False, Orientation:=xlLeftToRight


Also, in the "Columns.Select" statement, I would like to use the number in the variable "testcounter" to determine how many of the columns should be selected.

Any help would be greatly appreciated.

Thanks
--Rob
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top