Hello everyone, my name is A.Maurizio
And my problem is this:
It is possible using the vba, make sure that the columns of Sheet 1 from (A6: P2000) can be reordered in alphabetical order.
Because sometimes I do a lot of data transfer operations from sheet 2 to sheet 1; For here it would be useful to rearrange everything thanks.
(P.S) I insert a Reduced Test File
Hola chicos, ya no tienen en cuenta esta solicitud, ya que recordé dónde había puesto esta parte de mi código hace muchos años.
Por ser tan bueno, creo que cerré este mi post. Gracias.
(P.S) El Procedimiento luego esto: Para aquellos que lo Necesitan en el Futuro
Sub Ordina_Celle Range("A6:P2000").Sort Key1:=Range("A6"), Order1:=xlAscending, Header:=xlNo, _ OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom End Sub
I think your italian english was confusing enough, no need to change the language 🙂
For such tasks you should try the macro recorder. Your code sorts the rows based on the first column, it's not sorting the columns.
Here is what my recorder produced, the columns are ordered alphabetically now:
Sub Macro1()
ActiveWorkbook.Worksheets("Foglio1").Sort.SortFields.Clear
ActiveWorkbook.Worksheets("Foglio1").Sort.SortFields.Add Key:=Range("A5:P5") _
, SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:=xlSortNormal
With ActiveWorkbook.Worksheets("Foglio1").Sort
.SetRange Range("A5:P10")
.Header = xlYes
.MatchCase = False
.Orientation = xlLeftToRight
.SortMethod = xlPinYin
.Apply
End With
End Sub