Rango a ordenar con macro
Tengo el siguiente código:
Private Sub ORAZ() Sheets("Hoja 1").Select
A = InputBox("INGRESA LA LETRA DE LA COLUMNA QUE QUIERES ORDENAR", "ORDENAR A/Z", , 500, 500)
ActiveSheet.Unprotect "ábrete" ActiveWorkbook.Worksheets("Hoja 1").AutoFilter.Sort.SortFields.Clear ActiveWorkbook.Worksheets("Hoja 1").AutoFilter.Sort.SortFields.Add Key:= _ Range("" & A & "9:" & A & "1009"), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption _ :=xlSortNormal With ActiveWorkbook.Worksheets("Hoja 1").AutoFilter.Sort .Header = xlYes .MatchCase = False .Orientation = xlTopToBottom .SortMethod = xlPinYin .Apply End With
ActiveSheet.Protect Password:="ábrete", DrawingObjects:=False, Contents:=True, Scenarios:= _ False, AllowFormattingCells:=True, AllowFormattingColumns:=True, _ AllowFormattingRows:=True, AllowInsertingRows:=True, _ AllowInsertingHyperlinks:=True, AllowDeletingRows:=True, AllowSorting:= _ True, AllowFiltering:=True, AllowUsingPivotTables:=True ActiveSheet.EnableSelection = xlNoRestrictions
End Sub
Lo que hace es ordenar en orden ascendente los datos dentro del rango A (que es variable) 9 al A 1009.
El problema es en la columna I en donde desde la fila 9 hasta la 1009 hay fórmulas, es decir, no hay celdas en blanco.
Al correr la macro me amplía el rango hasta después de la fila 1009 y me toma en cuenta de la fila 1010 y hasta la 1015 en donde tengo sub totales.
Espero puedan ayudarme diciéndome cómo puedo hacer para que solo y siempre me tome en cuenta el rango A (que es variable) 9 al A 1009.