2014-10-30 88 views
-2
Dim cmdString As String 
Dim apptype As String 

cmdString = InputBox("Enter Application type") 

For Each Cl In ActiveSheet.Range("F3:Q54") 
    If Cl.Value = cmdString Then 
    Exit For 
    End If 
Next Cl 

代碼獲取該列值,但我想要獲取同一行的另一列單元格值。我怎麼做?搜索excel列單元格值

回答

1

可以使用Offset屬性訪問相對細胞與當前小區:

... 
If Cl.Value = cmdString Then 
    otherValue = Cl.Offset(0, num).Value 
    Exit For 
End If 
... 

其中num在其中其它小區所位於的列(左當前小區的列的負數的偏移,當前單元右邊的正數)。

相關問題