It won't hurt to try

다른 파일 시트에서 문자열 검색 본문

VBA

다른 파일 시트에서 문자열 검색

yongki.doki 2020. 10. 7. 21:29
Sub Button1_Click()
    ' variable
    Dim file_path As String '검색파일주소
    Dim sheet_name As String '검색시트명
    Dim search_area As String '검색영역
    Dim search_start As String '검색시작셀
    Dim rng As Variant
    
    ' init
    file_path = Range("I2").Value
    sheet_name = Range("I3").Value
    search_area = Range("I4").Value
    search_start = "H13"
    
    ' get data
    Application.Workbooks.Open FileName:=file_path
    rng = Sheets(sheet_name).Range(search_area).Value
    ActiveWorkbook.Close
 
    ' compare
    Range(search_start, ActiveSheet.Range(search_start).End(xlDown)).Select
    
    Set rMulti = Selection.Cells()

    For Each rCol In rMulti.Columns
        For Each rCell In rCol.Rows
            For i = LBound(rng) To UBound(rng)
                For j = LBound(rng, 2) To UBound(rng, 2)
                    If InStr(rng(i, j), Range(rCell.Address).Value) Then
                        Range(rCell.Address).Offset(0, 1) = "O"
                    End If
                Next j
            Next i
        Next rCell
    Next rCol
        
        
End Sub

 

https://excelmacromastery.com/vba-for-loop/

 

VBA For Loop - A Complete Guide - Excel Macro Mastery

The post provides a complete guide to the VBA For Loop and the VBA For Each loop. Use the quick guide table to see real world examples of For and For Each.

excelmacromastery.com

https://mainia.tistory.com/3877

 

엑셀 VBA 셀 영역 선택하는 여러가지 방법

엑셀 VBA 셀 영역 선택하는 여러가지 방법 환경: Microsoft Excel 2013 VBA 에서 가장 많이 쓰이는 소스는 영역을 선택하고 데이터를 가져오는 부분입니다. 시트에 있는 값을 분석하기 위해서는 일단 필�

mainia.tistory.com

 

 

엑셀 VBA 셀 영역 선택하는 여러가지 방법

엑셀 VBA 셀 영역 선택하는 여러가지 방법 환경: Microsoft Excel 2013 VBA 에서 가장 많이 쓰이는 소스는 영역을 선택하고 데이터를 가져오는 부분입니다. 시트에 있는 값을 분석하기 위해서는 일단 필�

mainia.tistory.com

 

300x250
300x250

'VBA' 카테고리의 다른 글

모든 시트의 표시형식을 바꾸기  (0) 2022.12.19
[VBA]시트행지우기2  (0) 2022.09.14
[VBA]시트행지우기1  (0) 2022.08.29
text join 함수  (0) 2020.10.30
Comments