excel - 搜索整列中的行
问题描述
我正在编写一个简单的 Excel VBA 程序来搜索整个客户端数据库,寻找特定的记录。在执行此操作时,我遇到了一个问题 - 在遇到第一场比赛后,它会很好地执行指令并停止。
该数据库由 500 多行组成,如下所示:
A 列 B 列 C 列 D 列
姓名 xxxx yyy zzzz
这是一些简化的代码
Sub Analizuj_1_Click()
Dim SearchName As String
Dim CColumn As Integer
Dim Match As Boolean
Dim CRow As Integer
Dim CRowPaste As Integer
On Error GoTo Err_Execute
LDate = Range("NazwaKlienta").Value
Sheets("2019").Select
'Starting in Column A, Row 2'
LColumn = 1
LRow = 2
LRowPaste = 2
LFound = False
While LFound = False
'Found a blank cell -> terminate'
If Len(Cells(CRow, 1)) = 0 Then
MsgBox "Klient nie ma zaległości"
Exit Sub
'Found Match
Szukaj: ElseIf Cells(CRow, 1) = SearchName Then
Cells(CRow, 1).EntireRow.Select
Selection.Copy
Sheets("test").Select
Cells(CRowPaste, 1).Select
Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone, SkipBlanks:= _
False, Transpose:=False
LFound = True
CRowPaste = CRowPaste + 1
Sheets("2019").Select
'Continuation"
ElseIf Cells(CRow, 1).Value > 0 Then
CRow = CRow + 1
GoTo Szukaj
End If
Wend
Exit Sub
Err_Execute:
MsgBox "Blad."
End Sub
即使我尝试通过 Start 语句继续搜索,它也会在第一个找到的匹配项处停止。我尝试尝试其他方法,但仍然是同样的问题。
Inb4 我知道,选择不是最有效的方法
解决方案
推荐阅读
- php - 使用 google Drive api 上传后如何获取 google drive 文件 ID?
- c# - HttpWebRequest 适用于 windows 窗体但不适用于 Web API
- python - parsed_json = kstream.map(lambda (k,v): json.loads()),无效语法错误问题
- html - 纯粹使用 HTML + CSS 创建下拉菜单
- java - 无法将屏幕截图添加到 Cucumber 中的范围报告中
- javascript - 如何从javascript中的对象数组映射多个属性
- sql - 通过日期过滤器查找小时差异
- node.js - 如何使用 nvm 安装节点 9?
- logging - cron 输出到文件中
- c++ - c++程序用LAPACK库编译