单元格焦点来自另一张工作表双击Vba Excel


Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
Dim f As Range
If Target.Count = 1 Then
If Not Intersect(Target, Me.Range("C:C")) Is Nothing Then
Set f = ThisWorkbook.Sheets("TARJETAS").Columns("B:B").Find( _
what:=Target.Value, lookat:=xlWhole)
If Not f Is Nothing Then
Cancel = True
HojaCliente.Activate
f.Select
End If
End If
End If
End Sub

我正在尝试重新创建以下事件:双击工作表中我所在的单元格,我想将注意力集中在具有相同元素但位于另一个工作表上的行上。

我设法选择了单元格,但我无法浏览所有这些列,然后将自己定位在该列中。

我应该遍历另一张表上的所有列,然后执行if条件吗?

类似这样的东西:

Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
Dim f As Range, wsSearch As Worksheet
If Target.Count = 1 Then
If Not Intersect(Target, Me.Range("L:L")) Is Nothing Then
Set wsSearch = ThisWorkbook.Sheets("Hoja8")
Set f = wsSearch.Columns(3).Find( _
what:=Target.Value, lookat:=xlWhole)
If Not f Is Nothing then
Cancel = True
wsSearch.Activate
f.Select
End If
End If
End If
End Sub

调整:

  • Range("L:L")到您双击的列
  • "Hoja8"到要搜索的图纸名称
  • Columns(3)到要搜索值的列

相关内容

最新更新