在VBA宏中获取错误438

时间:2011-04-27 02:17:13

标签: vba excel-vba excel

我在Excel中有以下子

Sub MapEditor()
Dim title As String
Dim tx, ty As Integer
Dim wall As String
Dim wx, wy As Integer
Dim fa As String
Dim fax, fay As Integer
Dim ora As String
Dim orax, oray As Integer
Dim datax, datay As Integer
Dim datacolumn, datarow As Integer
datacolumn = ActiveCell.Column
datarow = ActiveCell.Row
Dim dwidth As Integer, dheight As Integer
Dim i As Integer
i = 1
Do While Sheets("BaseDataFightMap").Cells(1, i) <> ""
    Select Case Sheets("BaseDataFightMap").Cells(1, i).Variant
     Case Is = "width"
       dwidth = Sheets("BaseDataFightMap").Cells(Row, i).Value
     Case Is = "height"
        dheight = Sheets("BaseDataFightMap").Cells(Row, i).Value
    End Select
    i = i + 1
Loop

但它给了我一个错误438,我做错了什么?

2 个答案:

答案 0 :(得分:2)

尝试更改Case语句:

Case Is = "width"

为:

Case "width"

答案 1 :(得分:2)

没有像变种那样的细胞属性

 Sheets("BaseDataFightMap").Cells(1, i).Variant

你在检查单元格的值(1,i)吗?

Sheets("BaseDataFightMap").Cells(1, i).Value?

此外,在您的代码中,变量Row没有标注或分配,因此这两行不起作用。

dwidth = Sheets("BaseDataFightMap").Cells(Row, i).Value
dheight = Sheets("BaseDataFightMap").Cells(Row, i).Value