|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
Public Sub wer()
Dim y, x, ce, blank As Range, i, j, d, str, str1, ran1 As Range
y = ActiveSheet.UsedRange.Rows.Count
x = Cells(1, Columns.Count).End(xlToLeft).Column
For Each ce In Range(Cells(1, 1), Cells(1, x))
If ce = "" Then
If blank Is Nothing Then Set blank = ce Else Set blank = Union(blank, ce)
End If
Next ce
If Not blank Is Nothing Then blank.EntireColumn.Delete
x = Cells(1, Columns.Count).End(xlToLeft).Column
For i = 1 To x
For j = 1 To y
str = str & Application.Small(Range(Cells(1, i), Cells(y, i)), j)
Next j
Cells(y + 1, i) = str
str = ""
Next i
y = ActiveSheet.UsedRange.Rows.Count
For i = 1 To x
If Application.Match(Cells(y, i).Value, Rows(y), 0) <> i Then
If ran1 Is Nothing Then Set ran1 = Cells(y, i) Else Set ran1 = Union(ran1, Cells(y, i))
End If
Next i
If Not ran1 Is Nothing Then ran1.EntireColumn.Delete
Rows(y).ClearContents
End Sub
[ 本帖最后由 doitbest 于 2011-6-27 13:48 编辑 ] |
|