EXCEL或者WPS中筛选函数的问题,求达人指教,很急!在线等。。

2025-04-30 03:54:46
推荐回答(3个)
回答1:

放在ThisWorkbook中:

Private Sub Workbook_SheetSelectionChange(ByVal Sh As Object, ByVal Target As Range)
Dim col, ncol As Byte
Dim selValue As String
Dim i As Integer
Const countRow = 1000 '行数自己设

If Target.Count > 1 Or Target.Column > 2 Then
MsgBox "只能选A列或B列的一个单元格!!!", vbCritical, "错误"
Exit Sub
End If
col = Target.Column()
selValue = Target.Value
With ActiveSheet
.Range("A1:B" & countRow).Interior.Pattern = xlNone

If col = 1 Then
ncol = 2
Else
ncol = 1
End If
i = 1
While i < countRow
If .Cells(i, ncol) = selValue Then
.Cells(i, ncol).Interior.Color = 255
End If
i = i + 1
Wend

End With
End Sub

回答2:

这个,除了用VBA
不出来别的办法

回答3:

说具体点,最好有图片。