excel - VBA子没有进入功能
问题描述
我在 Excel 工作簿的不同工作表中创建了以下函数,它们都由子执行。但是,当我启动子程序时,它不会访问函数并直接跳过If
语句。
Sheet1 功能:
Public Function ndg(row As Range) As Integer
ndg = Range("b" & row).Value
End Function
Function Checkispraticaforeclosure(row As Range)
Dim ndga As Integer
Dim rowindex As Integer
ndga = ndg(row)
rowindex = Sheet6.findrownumberndg(ndga)
If Sheet6.ispositionforeclosure(rowindex) = True Then
row.Cells(33) = Sheet6.getforeclosurecode(rowindex)
Checkispraticaforeclosure = True
Else
Checkispraticaforeclosure = False
End If
End Function
Sub insertcode(row As Range)
Dim ndga As Integer
Dim rowindex As Integer
ndga = ndg(row)
rowindex = Sheet6.findrownumberndg(ndga)
If Sheet6.ispositionforeclosure(rowindex) = False Then
row.Cells(33) = "ok"
End If
End Sub
Sheet6 功能:
Public Function findrownumberndg(ndg As Integer) As Integer
Set foundcell = Sheet6.Range("a:a").Find(ndg, lookat:=xlWhole)
If Not foundcell Is Nothing Then
findrownumberndg = 0
Else
findrownumberndg = foundcell.row
End If
End Function
Public Function ispositionforeclosure(row As Integer) As Boolean
If Range("D" & row).Value = "Foreclosure procedure" Then
ispositionforeclosure = True
Else
ispositionforeclosure = False
End If
End Function
Public Function getforeclosurecode(row As Integer)
getforeclosurecode = Range("f" & row).Value
End Function
执行子:
Public Function sheet1lastrow()
lastrow = Sheet1.Cells(Rows.Count, "b").End(xlUp).row
End Function
Sub masterinsertcode()
For x = 6 To ThisWorkbook.sheet1lastrow()
Dim checked
checked = False
Dim currentrow As Range
Set currentrow = Sheet1.Rows(x)
checked = Sheet1.Checkispraticaforeclosure(currentrow)
If checked = False Then
Sheet1.insertcode (currentrow)
End If
Next
End Sub
我不确定为什么执行子没有进入我创建的检查并直接转到End Sub
.
解决方案
推荐阅读
- unity3d - 从 Unity 资源包中实例化光子场景对象
- machine-learning - 我应该通过深度学习在人脸验证上使用 0 类吗?
- python - 输出 zabbix-api 值历史
- javascript - 调度一个动作不是用结果设置 redux
- java - 带有 inter_word justificationMode 的可选 TextView
- c - 我查找 LCS 的代码返回一个空矩阵
- vb.net - 如何仅从 Word 表格中的选定单元格中获取文本?
- javascript - html中的平方根
- c++ - 如何创建一个在其中执行其他功能的函数
- c++ - 如何返回值为 NULL 的变量指针