20210211 0920 

 

Ref

[1] "docs.microsoft.com/en-us/office/vba/api/excel.range.find"

 

Syntax

expression.Find (What, After, LookIn, LookAt, SearchOrder, SearchDirection, MatchCase, MatchByte, SearchFormat)

expression A variable that represents a Range object.

 

① Range가 찾는 범위

② Range에 찾는 항목이 여러 개 있다면?

 

exampe [1]

This example finds all cells in the range A1:A500 in worksheet one that contain the value 2, and changes the entire cell value to 5. That is, the values 1234 and 99299 both contain 2 and both cell values will become 5.

Sub FindValue()
    
    Dim c As Range
    Dim firstAddress As String

    With Worksheets(1).Range("A1:A500") 
        Set c = .Find(2, lookin:=xlValues) 
        If Not c Is Nothing Then 
            firstAddress = c.Address 
            Do 
                c.Value = 5 
                Set c = .FindNext(c) 
            Loop While Not c Is Nothing
        End If 
    End With
    
End Sub

 

 

 

'[PA] 업무자동화 > [XL]Excel & VBA' 카테고리의 다른 글

XL DAX Reference  (0) 2021.02.19
XL Relationship Database, Table  (0) 2021.02.17
XL copy sheets and save them as value  (0) 2021.02.11
XL saving/printing multiple sheets in on PDF file  (0) 2021.02.11
XL internal data model  (0) 2021.02.08
Posted by Weneedu
,


출처: https://privatedevelopnote.tistory.com/81 [개인노트]