LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7
Default Problem sorting a range of columns using VBA

Thanks all but after recording a macro again and tweaking it slightly,
came up with the below code which seems to work perfectly.

Workbooks(glbMasterFileName).Worksheets("System Data").Activate
LastUsedEmplRow = (Worksheets("System
Data").Range("F65536").End(-4162).Row) - 0 'Returns last used row

Range("F2:H" & LastUsedEmplRow).Select
ActiveWorkbook.Worksheets("System Data").Sort.SortFields.Clear
ActiveWorkbook.Worksheets("System Data").Sort.SortFields.Add
Key:=Range("F2") _
, SortOn:=xlSortOnValues, Order:=xlAscending,
DataOption:=xlSortNormal
With ActiveWorkbook.Worksheets("System Data").Sort
.SetRange Range("F3:H" & LastUsedEmplRow)
.Header = xlNo
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With

Thanks,
Lakehills
 
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
Sorting a named range using first three columns Del Cotter Excel Programming 5 September 7th 08 11:04 AM
Problem with sorting by date columns Dupatt Excel Discussion (Misc queries) 0 January 21st 08 01:09 AM
Problem Sorting Excel Range in VBS [email protected] Excel Programming 1 August 17th 07 10:54 PM
Problem with Range and Sorting Data Elise148 Excel Discussion (Misc queries) 0 July 5th 07 03:40 PM
Button to sort a range, and sorting 12 columns [email protected] Excel Worksheet Functions 2 October 19th 06 04:14 AM


All times are GMT +1. The time now is 01:38 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"