arrays - 根据数组删除匹配的 SSN
问题描述
我有一个私人子,我在代码末尾调用它。其目的是删除其 SSN 与正在运行的数组匹配的任何个人。我有两张纸可以搜索,第二张效果很好,但是第一张似乎不起作用。
我试图调试它,它找到了我关心的一个人与数组匹配的正确数字,但If statement
似乎并没有影响它。这是我所拥有的,任何和所有的帮助将不胜感激。同样的问题是第一个If statement
工作不正常。出于安全原因,我显然更改了 SSN。再次感谢!
Private Sub Delete_Deceased()
Dim tw As Workbook: Set tw = ThisWorkbook
Dim visa As Worksheet: Set visa = tw.Worksheets("Visa")
Dim nav As Worksheet: Set nav = tw.Worksheets("Navigator")
Dim rwCnt_visa As Long: rwCnt_visa = visa.Cells(Rows.Count, 1).End(xlUp).Row
Dim rwCnt_nav As Long: rwCnt_nav = nav.Cells(Rows.Count, 1).End(xlUp).Row
Dim x As Long
Dim y As Long
Dim Deceased() As Variant
Deceased = Array(123456789, 234567890, 345678901, 456789012, 567890123, 678901234, _
789012345, 890123456, 901234567)
Dim visa_Inx As Long
Dim nav_Inx As Long
visa.Columns("P:P").NumberFormat = "@" 'Format the VISA SSN column as text
For x = rwCnt_visa To 4 Step -1
For visa_Inx = LBound(Deceased) To UBound(Deceased)
If visa.Cells(x, 16).Value2 = Deceased(visa_Inx) Then
Debug.Print "Row: " & x
'visa.Rows(x).Delete shift:=xlShiftUp
End If
Next visa_Inx
Next x
For y = rwCnt_nav To 2 Step -1
For nav_Inx = LBound(Deceased) To UBound(Deceased)
If nav.Cells(y, 5).Value2 = Deceased(nav_Inx) Then
nav.Rows(y).Delete shift:=xlShiftUp
End If
Next nav_Inx
Next y
End Sub
解决方案
似乎是基础数据的问题,也许尝试CLng
在单元格值上使用。
If CLng(visa.Cells(x, 16).Value2) = Deceased(visa_Inx) Then
推荐阅读
- swift - 我在 TableViewCells 中有 CollectionView 单元格。我在根据不同的模拟器调整 UIImageView 宽度时遇到问题
- powershell - 编写摘要日志并从脚本中捕获错误
- regex - Kubernetes 入口重写目标和重写正则表达式/捕获组 (?i)
- r - 如何替换r中的列中的条目
- r - 在 R Markdown 上嵌入 shinyapps.io 应用程序的问题
- haskell - 如何从列表中返回列表 Haskell
- python - 没有 nginx 的 AWS ALB 背后的 Gunicorn
- azure - 从 Azure 部署的应用程序调用时如何解决外部 API 延迟?
- websocket - Micronaut - 将 WebSocketSession 持久化到 redis
- javascript - 如何将字符串数组变成键值对对象,使值成为数组?