Private Sub Worksheet_SelectionChange(ByVal Target As Range)
RR = Target.Row
CC = Target.Column
If RR = 3 And CC <= 4 Then
LR = Range("B3").End(xlDown).Row
ActiveWorkbook.Worksheets("品種名(1)").Sort.SortFields.Clear
ActiveWorkbook.Worksheets("品種名(1)").Sort.SortFields.Add Key:=Target.Resize(LR, 1), _
SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:=xlSortNormal
With ActiveWorkbook.Worksheets("品種名(1)").Sort
.SetRange Range("A3:D" & LR)
.Header = xlYes
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
End If
End Sub作者: ML089 時間: 2016-5-22 20:51
' 放在 ThisWorkbook,
' 其他工作表的 Private Sub Worksheet_SelectionChange(ByVal Target As Range) 請關閉或刪除
'
Private Sub Workbook_SheetSelectionChange(ByVal Sh As Object, ByVal Target As Range)
Dim xDat As Range, xKey As Range, LR
' Debug.Print Sh.Name
' Debug.Print Target.Address
'
If Application.Intersect([A3:D3], Target) Is Nothing Then Exit Sub