本文介绍了另一个工作表中的单元格焦点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
我正在尝试重新创建以下事件:双击工作表中我所位于的单元格,我想将焦点放在具有相同元素但在另一工作表上的行上.
I am trying to recreate the following event: Double click on a cell in the sheet where I am located and I want to focus on that row that has the same element but on another sheet.
我设法选择了单元格,但是我无法遍历所有这些列,然后将自己置于该列中.
I manage to select the cell but I can't manage to go through all those columns and then position myself in that column.
我应该遍历另一张纸上的所有列,然后进行if条件操作吗?
Should I do some traversal of all the columns on the other sheet and then do an if conditional?
推荐答案
类似以下内容:
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)
到要搜索值的列
Range("L:L")
to the column where you are double-clicking"Hoja8"
to the sheet name where you want to searchColumns(3)
to the column where you want to search for the value
这篇关于另一个工作表中的单元格焦点DoubleClick Vba Excel的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!