点击文件名下载附件
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Cells.Interior.ColorIndex = 0
Dim RG As Range, RGS As Range, R As Range, I%
Set RG = ActiveCell
Set RGS = Target
For Each R In RGS
If R = RG Then
R.Interior.ColorIndex = 3
I = I + 1
End If
Next R
MsgBox I
End Sub
点击文件名下载附件
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Cells.Interior.ColorIndex = 0
Dim RG As Range, RGS As Range, R As Range, I%
Set RG = ActiveCell
Set RGS = Target
For Each R In RGS
If R = RG Then
R.Interior.ColorIndex = 3
I = I + 1
End If
Next R
MsgBox I
End Sub
wp8680 发表于 2016-2-29 09:40
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Cells.Interior.ColorIndex = 0
...
就这个,你用第二种方法
Sub s()
Dim c As Range, rg As Range
t = [a1]
Set rg = [a1]
For Each c In [a1:d10]
If c = t Then
k = k + 1
Set rg = Application.Union(rg, c)
End If
Next
rg.Select
MsgBox k
End Sub