在VBA宏中获取错误438

时间:2022-01-27 02:27:18

I have the following sub in 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

But it's giving me an error 438, what am I doing wrong?

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

2 个解决方案

#1


2  

Try changing the Case statements from:

尝试更改Case语句:

Case Is = "width"

to:

Case "width"

#2


2  

There is no such cell property as variant

没有这样的细胞属性作为变体

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

Are you checking the VALUE of cell(1,i)?

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

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

Also, in your code the variable Row isn't dimensioned or allocated so these 2 lines will not work yet.

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

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

#1


2  

Try changing the Case statements from:

尝试更改Case语句:

Case Is = "width"

to:

Case "width"

#2


2  

There is no such cell property as variant

没有这样的细胞属性作为变体

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

Are you checking the VALUE of cell(1,i)?

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

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

Also, in your code the variable Row isn't dimensioned or allocated so these 2 lines will not work yet.

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

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