最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

vba - Multiple find in Excel - Stack Overflow

programmeradmin1浏览0评论

Here is my script

Foreach ($Object in $ABC) {

    try {

        $Cell = ($AAA.Columns.Item($AAA_COL.'A').Find($Object.Cell,[Type]::Missing,[Type]::Missing,1)).Row

        $AAA.Cells.Item($Cell,$AAA_COL.'A1') = $Object.Number1
        $AAA.Cells.Item($Cell,$AAA_COL.'A2') = $Object.Number2
        $AAA.Cells.Item($Cell,$AAA_COL.'A3') = $Object.Number3
        $AAA.Cells.Item($Cell,$AAA_COL.'A4') = $Object.Number4

    }

    catch {}

    $null = $Object = $Cell

}

It works but only match up the first find (YES) and skip the rest.

I have tried to do each row first but then that would take forever. This is what I use now however it takes around 20 mins to run.

Foreach ($Object in $AAA) {

try {

    $Cell = $Object.Row

    $AAA.Cells.Item($Cell,$AAA_COL.'A1') = ($ABC | Where-Object{$_.Number -eq $Object.A}).Number1
    $AAA.Cells.Item($Cell,$AAA_COL.'A2') = ($ABC | Where-Object{$_.Number -eq $Object.A}).Number2
    $AAA.Cells.Item($Cell,$AAA_COL.'A3') = ($ABC | Where-Object{$_.Number -eq $Object.A}).Number3
    $AAA.Cells.Item($Cell,$AAA_COL.'A4') = ($ABC | Where-Object{$_.Number -eq $Object.A}).Number4

}

catch {}

$null = $Object = $Cell

}

Any suggestions?

发布评论

评论列表(0)

  1. 暂无评论