本文介绍了如何通过vba代码Cells.Find在excel列中找到一个值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我必须在Excel表中找到一个值 celda 。我正在使用这个vba代码来找到它:

I have to find a value celda in an Excel sheet. I was using this vba code to find it:

Set cell = Cells.Find(What:=celda, After:=ActiveCell, LookIn:= _
    xlFormulas, LookAt:=xlWhole, SearchOrder:=xlByRows, SearchDirection:= _
    xlNext, MatchCase:=False, SearchFormat:=False)


If cell Is Nothing Then
    'do it something

Else
    'do it another thing
End If

问题是当我必须在excel列中找到值。我找到了下一个代码:

The problem is when I have to find the value only in a excel column. I find it with next code:

    Columns("B:B").Select
    Selection.Find(What:="VA22GU1", After:=ActiveCell, LookIn:=xlFormulas, _
        LookAt:=xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
        MatchCase:=False, SearchFormat:=False).Activate

但是我不知道如何适应第一个vba代码,因为我必须使用的值

But I don't know how to adapt it to the first vba code, because I have to use the value nothing.

推荐答案

只需使用

Columns("B:B").Select
Set cell = Selection.Find(What:="celda", After:=ActiveCell, LookIn:=xlFormulas, _
        LookAt:=xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
        MatchCase:=False, SearchFormat:=False)

If cell Is Nothing Then
    'do it something

Else
    'do it another thing
End If

这篇关于如何通过vba代码Cells.Find在excel列中找到一个值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-27 05:03