vba - VBA,从输入框中过滤输入以删除行
问题描述
通过导出数据 excel 创建一个新的工作簿。我有一个输入框要输入,应该导出哪个日期,使用以下代码,效果很好。
ReEnter:
Dim AddDate As String
AddDate = InputBox("Enter date for export.", "Enter date", "DD.MM.YYYY")
If Not Format(AddDate, "DD.MM.YYYY") = AddDate Then
MsgBox "Wrong format. Use DD.MM.YYYY."
GoTo ReEnter
Else
If AddDate = "" Then
Workbooks("PEKLAR.xlsm").Close
GoTo The_End
End If
End If
Workbooks("PEKLAR.xlsm").Activate
Dim FoundRange As Range
Set FoundRange = Range("A:A").Find(what:=DateValue(AddDate), LookIn:=xlFormulas, lookat:=xlWhole)
If FoundRange Is Nothing Then
MsgBox "Date not found. Please try again."
GoTo ReEnter
Else
Dim i As Long
Application.EnableEvents = False
With Worksheets("PEKLAR")
For i = .Cells(.Rows.Count, 1).End(xlUp).Row To 3 Step -1
Select Case LCase(.Cells(i, 1).Value)
Case AddDate
'do nothing
Case Else
.Rows(i).EntireRow.Delete
End Select
Next i
Workbooks("PEKLAR.xlsm").Worksheets("PEKLAR").Range("A2:W2500").AutoFilter Field:=22, Criteria1:="kein Fehler"
Workbooks("PEKLAR.xlsm").Worksheets("PEKLAR").Range("A3:W2500").SpecialCells(xlCellTypeVisible).EntireRow.Delete
On Error Resume Next
Workbooks("PEKLAR.xlsm").Worksheets("PEKLAR").ShowAllData
End With
Application.EnableEvents = True
Workbooks("PEKLAR.xlsm").Close True
End If
现在我希望用户一次输入多个日期。我已经尝试使用 split(AddDate, ",") 但我没有得到正确的代码来拆分日期,如果找到输入的日期/日期(也只有一个日期),请查看 A 列,删除包含任何其他日期的行(仅保留输入的日期),然后删除第 22 列中包含“kein Fehler”的行。
任何帮助都会得到帮助。
先感谢您。
解决方案
推荐阅读
- docker - 寻找一个示例 docker-compose 文件让 traefik 反向代理容器和非容器服务
- amazon-web-services - 使用 CodePipeline 从 VPC 调用 Lambda 失败并出现超时
- xquery - 条件组合索引:当有多种十进制类型的索引时,无法查询到想要的结果
- sql-server - 如何使用 T-SQL 生成 RSA-SHA1 签名?
- asp.net-core - 如何使用端点路由动态解析控制器?
- python-3.x - Python3中的实例属性可以不可变吗
- cython - 如何调用 cdef 方法
- java - 如何正确覆盖 Spring 中的内部配置文件?
- php - PHP Regex 模式获取指定的单词
- python - 密码锁程序