我有以下代码。我调试并得到问题是在for。里面的IF。
确切的错误是:运行时错误438 - 对象不支持此属性或方法
有什么线索可能是什么? 我感谢任何帮助。 谢谢!
Sub dimensiones()
Dim Hoja1 As Object
Dim Hoja2 As Object
Set Hoja1 = Worksheets("INPUT")
Set Hoja2 = Worksheets("OUTPUT")
Dim inicio_filas As Integer
Dim col_s1 As Integer
Dim col_s2 As Integer
Dim limite_filas As Integer
Dim m As Integer
col_s1 = 38
col_s2 = col_s1 + 2
inicio_filas = 3
limite_filas = 1000
Dim k As Integer
k = inicio_filas
For i = inicio_filas To limite_filas
For m = 1 To col_s2 - 1
Hoja2.Cells(k, m) = Hoja1.Cells(i, m)
Next m
k = k + 1
If Hoja1(i, col_s2) <> "" Then
For m = 1 To col_s1 - 1
Hoja2.Cells(k, m) = Hoja1.Cells(i, m)
Next m
Hoja2.Cells(k, col_s2) = Hoja1.Cells(i, col_s2)
Hoja2.Cells(k, col_s2 + 1) = Hoja1.Cells(i, col_s2 + 1)
Hoja2.Cells(k, col_s2 + 2) = Hoja1.Cells(i, col_s2 + 2)
k = k + 1
End If
Next i
End Sub
答案 0 :(得分:1)
得到它,noob错误,但在寻找Hoja1.Cells(i,col_s2)时忘记了Cells命令丢失
谢谢!