水平排序-每行独立于其他行 [英] Sort horizontally - each row independently of the other rows
本文介绍了水平排序-每行独立于其他行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想水平排序我的数据(字符串),但我想独立于其他行对每一行进行排序.
I would like to sort my data (strings) horizontally but I want to sort each row independently of the other rows.
唯一的方法是手动选择每一行并对其进行排序吗?
Is the only way of doing that is to select manually select each row and sort it?
我根本不是VBA专家,我可以在c#或java中做到这一点,但我希望该函数在excel中存在...
I am not an VBA expert at all, I could do that in c# or java but I hope that this function exist in excel ...
谢谢!
推荐答案
这里是VBA,假设您的最后一行在A列中有数据:
Here's the VBA for this, assuming your last row has data in column A:
Sub Macro1()
Dim lLastRow As Long, lLoop As Long
lLastRow = Cells(Rows.Count, 1).End(xlUp).Row
'turn off updates to speed up code execution
With Application
.ScreenUpdating = False
.EnableEvents = False
.Calculation = xlCalculationManual
.DisplayAlerts = False
End With
For lLoop = 1 To lLastRow
Rows(lLoop).Sort key1:=Cells(lLoop, 1), order1:=xlAscending, Header:=xlGuess, OrderCustom:=1, MatchCase:= _
False, Orientation:=xlLeftToRight, DataOption1:=xlSortNormal, DataOption2 _
:=xlSortNormal
Next
With Application
.ScreenUpdating = True
.EnableEvents = True
.Calculation = xlCalculationAutomatic
.DisplayAlerts = True
End With
End Sub
这篇关于水平排序-每行独立于其他行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文