2012-07-14 49 views
1

可能重复:
Find cell location based on value then do something- User Forms VBA Excel最擅长的搜索工作表,.. EXCEL VBA用户窗体

我建一个用户表,并试图找出如何写块代码:

*从用户获取组合框的值。 *搜索一个特定的板该值,在特定列 *获得的单元格位置的这个值 *返回地址一个办公组行,为城市”下一步偏移行

我问这个同样的问题之前,然而,一段时间后,答案不可能帮助

这里是我的代码,我想出了:。

For Each cLoc In ORISheetList.Range("ORI_LIST") 
'compare the input string from list- considering using Match function for this 
If StrComp(cLoc, ORIValue, vbTextCompare) Then TextBAgencyName.Value = "test" 
Else: Next cLoc 
End If 

的每个循环,如果条件句真的不很好地协同工作

我读过vba excel有一个find函数。有没有一种方法来获取细胞的位置?由于

回答

1

使用

Set cLoc = ORISheetList.Range("ORI_LIST").find ORIValue 
If not cLoc is nothing then 
    ' you found it!