つらつら Excel VBA

私の備忘録です。

オートフィルタ

'オートフィルタで絞り込み、必要列だけデータを取得する。
searchData = "*条件を含む*"
wsh.AutoFilterMode = False 'オートフィルタ解除
wsh.Range("A1").CurrentRegion.AutoFilter Field:=1, Criteria1:=searchData
Set targetRange = wsh.Range("A1").CurrentRegion.SpecialCells(xlCellTypeVisible)

For Each c In targetRange
    '1行目以外かつ5列目(タイトル行以外の指定データ列)
    If c.Row > 1 And c.Column = 5 Then
        getData = c.Value
    End If
Next c

Set targetRange = Nothing