Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() I need to sort a worksheet from columns A10:AE, with the last row of the sort procedure being two rows above where "XYZ" is found in column A. There are blank cells in the range also. For example: XYZ is in cell A110. I need to sort the using the range A10:AE108 Any and all help is greatly appreciated. |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
This should be close... You did not specify how youwanted the data sorted so
I sorted by column A with no header row. You also did not specify a sheet so you will have to change the code to suit... Sub SortStuff() Dim rngToSort As Range Dim rngFound As Range Dim wks As Worksheet Set wks = Sheets("Sheet1") Set rngFound = wks.Columns(1).Find(What:="xyz", _ LookAt:=xlWhole, _ LookIn:=xlFormulas, _ MatchCase:=True) If rngFound Is Nothing Then MsgBox "Sorry, couldn't find xyz" Else Set rngToSort = Range("AE10", rngFound.Offset(-2, 0)) rngToSort.Sort Key1:=Range("A10"), _ order1:=xlAscending, _ Header:=xlNo End If End Sub -- HTH... Jim Thomlinson "jeffbert" wrote: I need to sort a worksheet from columns A10:AE, with the last row of the sort procedure being two rows above where "XYZ" is found in column A. There are blank cells in the range also. For example: XYZ is in cell A110. I need to sort the using the range A10:AE108 Any and all help is greatly appreciated. |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Macro to sort variable data range fails | Excel Discussion (Misc queries) | |||
Macro to Sort A-Z a variable range of cells | Excel Discussion (Misc queries) | |||
VBA Variable Range Sort | Excel Discussion (Misc queries) | |||
trim left of a found word in a text variable | Excel Programming | |||
Putting text in a column based on variable text from another colum | Excel Discussion (Misc queries) |