这是表格的样本(带有令人毛骨悚然的样本数据)
|Col A |Col B |Col C |Col D |Col E +------------+----------+--------+----------+----- |Number |Value |X |Date |Decimal |1 | AA|X |2012/01/01|.1 |2 | BB|X |2012/02/01|.2 |3 | CC|X |2012/03/01|.3 |4 | DD|X |2012/04/01|.4 |5 | EE|X |2012/05/01|.5
需要做什么:
条件:
到目前为止我做了什么:
问题:
任何帮助都是适当的
答案 0 :(得分:0)
Sub Tester()
Const SORT_HEADER As String = "Value"
Dim sht As Worksheet, f As Range
Set sht = Worksheets("Sheet1")
Set f = sht.Rows(1).Find(SORT_HEADER, LookIn:=xlValues, lookat:=xlWhole)
If Not f Is Nothing Then
sht.Range("A1").CurrentRegion.Sort _
Key1:=sht.Columns(f.Column), Order1:=xlAscending, Header:=xlYes
Else
MsgBox "'" & SORT_HEADER & "' column not found!"
End If
End Sub