VBA ---- 单、多条件筛选

单条件

> Option Base 1 
> Function ScreenOne(ByVal sourceArr As Variant, ByVal filedName As String, ByVal screenStr As String) As Variant
>     Dim targetArr As Variant
>     Dim targetFiledCol As Integer
>     Dim col As Integer
>     Dim iFiledCol As Integer
>     Dim i As Integer, j As Integer, k As Integer
>     With sht
>         '获取搜索字段所在列号
>         targetFiledCol = 0
>         For iFiledCol = 1 To UBound(sourceArr, 2)
>             targetFiledCol = targetFiledCol + 1
>             If sourceArr(1, targetFiledCol) = filedName Then
>                 Exit For
>             End If
>         Next iFiledCol
>         rowCount = 0
>         For iRow = 2 To UBound(sourceArr, 1)
>             If sourceArr(iRow, targetFiledCol) = screenStr Then
>                 rowCount = rowCount + 1
>             End If
>         Next iRow
>         
>         If rowCount = 0 Then
>             ReDim targetArr(1, UBound(sourceArr, 2))
>             For col = 1 To UBound(sourceArr, 2)
>                 targetArr(1, col) = sourceArr(1, col)
>             Next col
>             MsgBox filedName & " has no data names " & screenStr
>         Else
>         
>             ReDim targetArr(1 To rowCount + 1, 1 To UBound(sourceArr, 2))
>             For col = 1 To UBound(sourceArr, 2)
>                 targetArr(1, col) = sourceArr(1, col)
>             Next col
>             k = 2
>             For i = 2 To UBound(sourceArr, 1)
>                 If sourceArr(i, targetFiledCol) = screenStr Then
>                     For j = 1 To UBound(sourceArr, 2)
>                         targetArr(k, j) = sourceArr(i, j)
>                     Next j
>                     k = k + 1
>                 End If
>             Next i
>         End If
>     End With
>     ScreenOne = targetArr 
> End Function
多条件
> Function ScreenMore(ByVal sourceArr As Variant, ByVal filedName As String, ByVal screenArr As Variant) As Variant
>     
>     Dim targetArr As Variant
>     Dim targetFiledCol As Integer
>     Dim col As Integer
>     Dim iScreen As Integer
>     Dim iFiledCol As Integer
>     Dim i As Integer, j As Integer, k As Integer
>     With sht
>         '获取搜索字段所在列号
>         targetFiledCol = 0
>         For iFiledCol = 1 To UBound(sourceArr, 2)
>             targetFiledCol = targetFiledCol + 1
>             If sourceArr(1, targetFiledCol) = filedName Then
>                 Exit For
>             End If
>         Next iFiledCol
>         
>         rowCount = 0
>         For iRow = 2 To UBound(sourceArr, 1)
>             For iScreen = 1 To UBound(screenArr)
>                 If sourceArr(iRow, targetFiledCol) = screenArr(iScreen) Then
>                     rowCount = rowCount + 1
>                 End If
>             Next iScreen
>         Next iRow
>         
>         If rowCount = 0 Then
>             ReDim targetArr(1, UBound(sourceArr, 2))
>             For col = 1 To UBound(sourceArr, 2)
>                 targetArr(1, col) = sourceArr(1, col)
>             Next col
>             MsgBox filedName & " has no data names " & screenStr
>         Else
>         
>             ReDim targetArr(1 To rowCount + 1, 1 To UBound(sourceArr, 2))
>             For col = 1 To UBound(sourceArr, 2)
>                 targetArr(1, col) = sourceArr(1, col)
>             Next col
>             k = 2
>             For i = 2 To UBound(sourceArr, 1)
>                 For iScreen = 1 To UBound(screenArr)
>                     If sourceArr(i, targetFiledCol) = screenArr(iScreen) Then
>                         For j = 1 To UBound(sourceArr, 2)
>                             targetArr(k, j) = sourceArr(i, j)
>                         Next j
>                         k = k + 1
>                     End If
>                 Next iScreen
>             Next i
>         End If
>     End With
>     ScreenMore = targetArr 
> End Function
仅供参考,不解释

https://python-selenium-zh.readthedocs.io/zh_CN/latest/5.Waits/

from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC

class BasePage(object):
def init(self,chrome_driver,web_url):
self.chrome_driver_path=chrome_driver
self.web_url=web_url

    # 打开网页
    def SetUp(self):
        self.driver = webdriver.Chrome(self.chrome_driver_path)
        self.driver.maximize_window()
        self.driver.get(self.web_url)
    # 关闭网页
    def close_page(self):
        self.driver.quit()

class LoginPage(BasePage):
def init(self,chrome_driver,web_url):
BasePage.init(self, chrome_driver, web_url)
# 默认等待时间为20s
self.timeout = 20
def wait_input_element(self,ID_locator,input_text):
try:
WebDriverWait(self.driver, self.timeout).until(
EC.presence_of_element_located((By.ID, ID_locator))
).send_keys(input_text)
finally:
print(“yes”)
# driver.quit()

driver_path=r"C:\Program Files (x86)\Google\Chrome\Application\chromedriver.exe"
url =
driver=LoginPage(driver_path,url)
driver.SetUp()

Private Declare PtrSafe Function FindWindow Lib “user32” Alias “FindWindowA” (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Sub QQ1722187970()
Dim hwnd As Long
'用内置的属性获得excel应用程序句柄
hwnd = Excel.Application.hwnd
'用 FindWindow获得excel应用程序句柄
i = FindWindow(vbNullString, “Restart Required”)
'对比两个句柄值
Debug.Print hwnd, i
End Sub

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值