繁体   English   中英

来自另一张纸的单元格焦点 DoubleClick Vba Excel

[英]Cell Focus from another sheet DoubleClick 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

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

我设法 select 单元格,但我无法通过所有这些列来 go ,然后我自己在该列中 position 。

我是否应该遍历另一张纸上的所有列,然后执行 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)到要在其中搜索值的列

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM