2014-10-30 84 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在其中其它小区所位于的列(左当前小区的列的负数的偏移,当前单元右边的正数)。

相关问题