引用具有多个变量的单元格

时间:2018-06-04 07:14:58

标签: vba excel-vba excel

我分别定义了2个变量string和integer。使用需要的变量来引用单元格并采集数据。有人可以帮忙吗?

O(RlgN)

1 个答案:

答案 0 :(得分:3)

尝试

Option Explicit

Public Sub TEST()

    Dim OracleProjType As String
    Dim SearchProjNameRow As Long
    Dim OracleProjTypeData As String

    OracleProjType = "C" '<==Assign the value to the variable
    SearchProjNameRow = 6

    With Worksheets("Sheet3") '<== Work with that sheet using with so no activate
        OracleProjTypeData = .Range(OracleProjType & SearchProjNameRow).Value '<==Concatenate values to create range reference
        Debug.Print OracleProjTypeData
    End With
End Sub