excel 里面的vba 代码有控制单元格选中的事件吗
A1:A10选中这中间哪个单元格它的值就等于B1当然没值时不等B1选A1就A1=B1选A2就A2就A2=B1...
A1:A10
选中这中间哪个单元格它的值就等于B1
当然没值时不等B1选A1就A1=B1
选A2就A2就A2=B1 展开
选中这中间哪个单元格它的值就等于B1
当然没值时不等B1选A1就A1=B1
选A2就A2就A2=B1 展开
1个回答
展开全部
在SelectionChange中写代码,示范代码如下,你可以研究一下:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim cl
Set cl = ActiveCell
If Trim(Cells(1, 2).Value) = "" Then Exit Sub
If cl.Row >= 1 And cl.Row <= 10 And cl.Column = 1 Then
cl.Value = Cells(1, 2).Value
End If
End Sub
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim cl
Set cl = ActiveCell
If Trim(Cells(1, 2).Value) = "" Then Exit Sub
If cl.Row >= 1 And cl.Row <= 10 And cl.Column = 1 Then
cl.Value = Cells(1, 2).Value
End If
End Sub
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询