Excel Can';t将工作表类型与范围类型组合
我试图用一种方法得到一个单元格的值,我把表格放在一个参数中Excel Can';t将工作表类型与范围类型组合,excel,vba,Excel,Vba,我试图用一种方法得到一个单元格的值,我把表格放在一个参数中 Sub search(date1, month, sheet, index) Dim cell As Range Dim startDate As Integer Dim textoPlano As Integer Dim svcPoliza As Integer Dim svcMarcas As Integer Dim svcDptos As Integer Dim svcCotizacionesCme As Integer D
Sub search(date1, month, sheet, index)
Dim cell As Range
Dim startDate As Integer
Dim textoPlano As Integer
Dim svcPoliza As Integer
Dim svcMarcas As Integer
Dim svcDptos As Integer
Dim svcCotizacionesCme As Integer
Dim svcAniosVehiculo As Integer
Dim svcRiesgoVigente As Integer
Dim svcLineasVehiculos As Integer
Dim svcLeeLocalidades As Integer
Dim hoja As Worksheet
Dim ultimaFila As Long
Dim resultado As Worksheet
Set resultado = ActiveWorkbook.Worksheets("Resultados")
Set hoja = ActiveWorkbook.Worksheets(sheet)
If sheet = "Consolidado" Then
Set hoja = ActiveWorkbook.Worksheets("Consolidado")
End If
ultimaFila = hoja.Cells(hoja.Rows.Count, "G").End(xlUp).Row
For Each cell In Range("G3:G" & ultimaFila)
If InStr(cell.Value, "enviarCorreoTextoPlano") > 0 Then
textoPlano = textoPlano + 1
End If
If InStr(cell.Value, "svcPolizaRecienteVehiculo") > 0 Then
svcPoliza = svcPoliza + 1
End If
If InStr(cell.Value, "svcMarcasVehiculos") > 0 Then
svcMarcas = svcMarcas + 1
End If
If InStr(cell.Value, "svcLeeDptos") > 0 Then
svcDptos = svcDptos + 1
End If
If InStr(cell.Value, "svcLeeCotizacionesCme") > 0 Then
svcCotizacionesCme = svcCotizacionesCme + 1
End If
If InStr(cell.Value, "svcLeeAniosVehiculo") > 0 Then
svcAniosVehiculo = svcAniosVehiculo + 1
End If
If InStr(cell.Value, "svcRiesgoVigenteVehiculo") > 0 Then
svcRiesgoVigente = svcRiesgoVigente + 1
End If
If InStr(cell.Value, "svcLineasVehiculos") > 0 Then
svcLineasVehiculos = svcLineasVehiculos + 1
End If
If InStr(cell.Value, "svcLeeLocalidades") > 0 Then
svcLeeLocalidades = svcLeeLocalidades + 1
End If
Next cell
End Sub
我想说的是:
hoja.cell.Value
调试器显示此错误“未找到方法或数据成员”
我认为这个错误是因为工作表不知道那是什么
提前感谢:)。我用以下方法解决了这个问题:
For Each cell In Worksheets(sheet).Range("G3:G" & ultimaFila)
将工作表放在循环声明的范围之前。您使用的是VBA还是VB.NET?它们不是一回事。工作表没有
单元格
属性。您可能只需要单元格
,但需要向循环中添加一个工作表引用。我正在使用VBA。如何在循环中添加图纸引用?也许是hoja,牢房?感谢您的快速响应。对于范围内的每个单元格(“G3:G”和ultimaFila)
没有工作表。您需要什么还不清楚。代码已经包含hoja.Cells(hoja.Rows.Count,“G”)。如果这样做行得通,您打算如何处理hoja.cell.Value`?我在问题中的代码中没有看到这个?如果不了解上下文,就不可能提供合理的答案。