![]() |
Application-defined or object-defined error on simple sort
I have a very simple sort that is giving me an applicaiton-defined or
object defined error on the sort code. I know it is some sort of problem with me quailifying objects or something which I do not understand. All the code does is upon sheet activation read in a single dimension array from one sheet, write it to another sheet and then attempt to sort what was just written. The code is not in a module but in the sheet object. Dim StyleCount As Long Dim ArrayStyleCount As Long Dim StyleArray() As String Dim SortRange As Range Private Sub Worksheet_Activate() Application.DisplayFormulaBar = False CountStyles ReadStyles WriteStyles End Sub Sub CountStyles() With Sheets("Data") StyleCount = .Range(.Range("A3"), ..Range("A3").End(xlDown)).Rows.Count End With ReDim StyleArray(0 To StyleCount) End Sub Sub ReadStyles() With Sheets("Data") For ArrayStyleCount = 0 To StyleCount - 1 'Read in Style Number StyleArray(ArrayStyleCount) = ..Range("A3").Offset(ArrayStyleCount, 0).Value Next ArrayStyleCount End With End Sub Sub WriteStyles() With Sheets("StyleSort") .Range("A1", .Cells(ArrayStyleCount + 1, 1)).Value = _ WorksheetFunction.Transpose(StyleArray) .Range(.Range("A1"), .Range("A1").End(xlDown)).Sort 'GET ERROR ON THIS LINE End With End Sub I have been struggling with this for days and have done everyting that I know to do to get it to work. Thanks for any suggestions you can give me. Brent |
All times are GMT +1. The time now is 01:23 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com