2012-07-14 47 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!