>即時新聞-熱門

2009年6月14日星期日

EXCELVBA - 重覆選課

Sub 重覆選課()

'取列
i = 1

Range("C2").Select
Selection.End(xlDown).Select
x = ActiveCell.Row
rx = "a1:y" & x
'排序

Range("C2").Select
Range(rx).Sort Key1:=Range("C2"), Order1:=xlAscending, Key2:= _
Range("D2"), Order2:=xlAscending, Header:=xlGuess, OrderCustom:=1, _
MatchCase:=False, Orientation:=xlTopToBottom, SortMethod:=xlStroke, _
DataOption1:=xlSortNormal, DataOption2:=xlSortNormal
Range("C2").Select


While (i <> x)


If ActiveCell.Value = ActiveCell.Offset(1, 0).Value Then

ActiveCell.Offset(0, 1).Select

If ActiveCell.Value = ActiveCell.Offset(1, 0).Value Then
ActiveCell.Offset(0, 21).Value = "重覆選課"
ActiveCell.Offset(1, 21).Value = "重覆選課"
ActiveCell.Offset(0, -1).Select

Else
ActiveCell.Offset(0, -1).Select
End If

End If


ActiveCell.Offset(1, 0).Select





i = i + 1
Wend

'還原
Range("A2").Select
Range(rx).Sort Key1:=Range("A2"), Order1:=xlAscending, Header _
:=xlGuess, OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom _
, SortMethod:=xlStroke, DataOption1:=xlSortNormal



End Sub

1 评论:

匿名 说...

Uѕеful іnfo. Lucκy mе I discovered уouг web sitе unintentiοnаlly, аnd I аm stunned
why this аccіdеnt ԁid not took placе in adνance!
І bοokmarkеd іt.

Alѕo visit my blog post ... iphonerepairkl.my

 
妹咕數位學園歡迎網友們來信指教 妹咕信箱