팁 : 다른 언어는 Google 번역입니다. 방문하실 수 있습니다. English 이 링크의 버전.
로그인
x
or
x
x
회원가입
x

or

Excel에서 셀 값을 기준으로 행을 자동 필터링하는 방법은 무엇입니까?

일반적으로 Excel의 필터 기능을 사용하면 필요에 따라 데이터를 필터링 할 수 있지만 수동 셀 입력을 기반으로 셀을 자동 필터링하려면 셀에 기준을 입력하면 데이터를 한 번에 자동으로 필터링됩니다. Excel에서이 작업을 처리 할 수있는 좋은 아이디어가 있습니까?

VBA 코드로 입력 한 셀 값을 기반으로 행 자동 필터링

대소 문자를 구분하여 텍스트 길이 등의 여러 기준 또는 기타 특정 조건별로 데이터 필터링


VBA 코드로 입력 한 셀 값을 기반으로 행 자동 필터링


다음과 같은 범위의 데이터가 있다고 가정합니다. E1 및 E2 셀에 조건을 입력하면 데이터가 아래 스크린 샷과 같이 자동 필터링됩니다.

doc 자동 필터 1

1. 입력 한 셀 값에 따라 날짜를 자동 필터링하려면 워크 시트로 이동하십시오.

2. 시트 탭을 마우스 오른쪽 버튼으로 클릭하고 코드보기 컨텍스트 메뉴에서 튀어 나온 응용 프로그램 용 Microsoft Visual Basic 창에서 다음 코드를 복사하여 빈 칸에 붙여 넣으십시오. 모듈 창, 스크린 샷보기 :

VBA 코드 : 입력 된 셀 값에 따라 데이터 자동 필터링 :

Private Sub Worksheet_Change(ByVal Target As Range)
'Updateby Extendoffice 20160606
   If Target.Address = Range("E2").Address Then
       Range("A1:C20").CurrentRegion.AdvancedFilter Action:=xlFilterInPlace, CriteriaRange:=Range("E1:E2")
   End If
End Sub

doc 자동 필터 2

주의 사항: 위의 코드에서, A1 : C20 필터링 할 데이터 범위입니다. E2 기준으로 필터링 할 대상 값입니다. E1 : E2 기준 셀이에 따라 필터링됩니다. 필요에 따라 변경할 수 있습니다.

3. 이제 셀에 기준을 입력하면 E1 그리고, E2 키를 누릅니다 엔터 버튼 키를 누르면 데이터가 자동으로 셀 값으로 필터링됩니다.


대소 문자를 구분하여 텍스트 길이 등의 여러 기준 또는 기타 특정 조건별로 데이터 필터링

텍스트 길이, 대소 문자 구분 등 여러 기준 또는 기타 특정 조건으로 데이터를 필터링합니다.

Excel 용 Kutools수퍼 필터 기능은 강력한 유틸리티이므로이 기능을 적용하여 다음 작업을 완료 할 수 있습니다.

  • 여러 기준으로 데이터 필터링. 텍스트 길이로 데이터 필터링.
  • 대 / 소문자 별 데이터 필터링. 년 / 월 / 일 / 주 / 분기 별 날짜 필터링

doc-super-filter1

Excel 용 Kutools: 200 이상의 편리한 Excel 추가 기능으로 60 일 동안 아무런 제한없이 시도 할 수 있습니다. 지금 무료 평가판 다운로드 및 다운로드!


데모 : VBA 코드로 입력 한 셀 값을 기반으로 행 자동 필터링


Excel 용 Kutools-최고의 사무 생산성 도구 80 % 생산성 향상

  • 재사용: 빠르게 삽입 복잡한 수식, 차트 그리고 당신이 전에 사용했던 것; 셀 암호화 비밀번호로; 메일 링리스트 만들기 그리고 이메일을 보내 ...
  • 슈퍼 포뮬러 바 (여러 줄의 텍스트와 수식을 쉽게 편집); 레이아웃 읽기 (많은 셀을 쉽게 읽고 편집); 필터링 된 범위에 붙여 넣기...
  • 셀 / 행 / 열 병합 데이터 손실없이; 분할 셀 내용; 중복 행 / 열 결합... 중복 세포 방지; 범위 비교...
  • 복제 또는 고유를 선택하십시오. 행; 빈 행 선택 (모든 세포는 비어있다); 슈퍼 찾기 및 퍼지 찾기 많은 통합 문서에서; 랜덤 선택 ...
  • 정확한 사본 공식 참조를 변경하지 않는 다중 셀; 참조 자동 작성 여러 장에; 글 머리 기호 삽입, 확인란 등 ...
  • 텍스트 추출, 텍스트 추가, 위치 별 제거, 공간 제거; 페이징 소계 생성 및 인쇄; 셀 내용과 주석 간 변환...
  • 수퍼 필터 (필터 구성표를 저장하고 다른 시트에 적용); 고급 정렬 월 / 주 / 일별, 빈도 등; 특수 필터 대담하고 기울임 꼴로
  • 통합 문서와 WorkSheets 결합; 키 열을 기준으로 테이블 병합 데이터를 여러 시트로 분할; 일괄 변환 xls, xlsx 및 PDF...
  • 300 이상의 강력한 기능. Office / Excel 2007-2019 및 365를 지원합니다. 모든 언어를 지원합니다. 기업이나 조직에 쉽게 배포 할 수 있습니다. 60 일 무료 평가판 전체 기능.
kte 탭 201905

Office 탭 Office에 탭 인터페이스를 제공하여 작업을 훨씬 쉽게

  • Word, Excel, PowerPoint에서 탭 편집 및 읽기 사용, 게시자, 액세스, Visio 및 프로젝트.
  • 새 창보다는 동일한 창에서 새 탭으로 여러 문서를 열고 만들 수 있습니다.
  • 50 %만큼 생산성을 높이고 매일 수백 번의 마우스 클릭을 줄입니다!
오피셜
Say something here...
symbols left.
You are guest ( Sign Up? )
or post as a guest, but your post won't be published automatically.
Loading comment... The comment will be refreshed after 00:00.
  • To post as a guest, your comment is unpublished.
    tim · 1 months ago
    Hey guys,
    perfect Explanation, thank you very much.
    1 Little question: if I want to filter with 2,3 4 or more criterias how do I do this?
    For example I want to say I wanna see the Name Henry, with Grade 1 and this Age...so not just 1 criteria but for example 3..=?


    thanks for the respond


    Kind regards,


    TIM
    • To post as a guest, your comment is unpublished.
      skyyang · 1 months ago
      Hi, tim,
      To auto filter data based on multiple criteria, you should apply the below code: (please change the cell references to your need)

      Private Sub Worksheet_Change(ByVal Target As Range)
      'Update by Extendoffice
      Dim xVStr As String
      Dim xFStr As String
      xVStr = "E22:G22" 'the criteria that you want to filter based on
      xFStr = "E21:G22" 'the range contains the header of the criteria
      If Not (Intersect(Range(xVStr), Target) Is Nothing) Then
      Range("A1:C17").CurrentRegion.AdvancedFilter Action:=xlFilterInPlace, _
      CriteriaRange:=Range(xFStr)
      End If
      End Sub


      Please try, hope it can help you!
  • To post as a guest, your comment is unpublished.
    Bogdan · 2 months ago
    Hello,

    What if I got the filtered data in a different tab(sheet 2) in the same workbook and the cell that the filter needs to refer to is in the first tab(sheet 1). I used this VBA but is not working like that, only if I have both the criteria cell(E2 in this VBA) in the same tab with the filtered data(A1:C20)
  • To post as a guest, your comment is unpublished.
    mjr_awesome · 2 months ago
    There might be a mistake in the instructions. Instead of pasting the code into a blank Module, one should paste it into the Sheet window. For example, if the macro is to work on Sheet1, the code should be pasted into Microsoft Excel Objects -> Sheet1(Sheet1). Only then it works for me on Excel 2016.

    Thanks for the code!
    • To post as a guest, your comment is unpublished.
      skyyang · 2 months ago
      Hi, mjr,
      There is no mistake in this article, the article said, you should put the VBA code into the sheet module by right click the sheet name and then choose View Code to go to the module.
      But, your operation is correct as well.
      Thank you for your comment.
  • To post as a guest, your comment is unpublished.
    Robert · 7 months ago
    So I have a bunch of values and then a table of data. I am wondering if I can filter that table based on the values similarly to what is explained above. For example I would like to click on a cell that has the value of 3, which corresponds to 3 records(200 rows, 25 columns) that meet a condition and then have my table filtered to just show those records. An example of a condition would be, if one variable is great than 100. I have over 100 of these conditions which is why I would like my table to be linked to it in some way. Any help would be much appreciated. In your example provided, it would be similar to if you just wanted all ages over 3, 6, 9, 12 etc and then you had 25 similar variables.So to filter the table to show only records with age over 3 based on clicking a value from a list that says something like age>3 - 2 records, age>6 - 4 records etc
  • To post as a guest, your comment is unpublished.
    Elliott · 7 months ago
    Is there a way to have it continue to filter with additional boxes. When I write it as ElseIf, it only follows the ElseIf command.
  • To post as a guest, your comment is unpublished.
    murat yazici · 8 months ago
    Private Sub Worksheet_Change(ByVal Target As Range)
    'Updateby Extendoffice 20160606
    If Target.Address = Range("E2").Address Then
    Range("A1:C20").CurrentRegion.AdvancedFilter Action:=xlFilterInPlace, CriteriaRange:=Range("E1:E2")
    End If
    End Sub


    E2 HUCRESI YERINE E SUTUNUNUNA YAZILAN SON SATIRA GORE FILITRELEME YAPABILIR MI


    According the code mentioned above , is it possible to make filtration according the written data to the last row of column E ?


    I hope to get help and thanks for your help
    • To post as a guest, your comment is unpublished.
      skyyang · 8 months ago
      Hi, murat,
      The above code works well in the whole worksheet, you just need to change the cell references to your need. Please try it, thank you!
  • To post as a guest, your comment is unpublished.
    Kent · 8 months ago
    The VB script worked beautifully. Many thanks for the post!
  • To post as a guest, your comment is unpublished.
    Bob · 8 months ago
    What happens if you have GRADE11 and GRADE12 for example. Will the filter show these also if you try and filter
    on GRADE1?
    • To post as a guest, your comment is unpublished.
      skyyang · 8 months ago
      Hello, Bob,
      Yes, as you said, when entering part of the text you want to filter, all the cells contain the part text will be filtered out. So, if you type Grade1, all cells contain Grade1, Grade11, Grage123...will be filtered out.
  • To post as a guest, your comment is unpublished.
    Mark · 9 months ago
    Thank you for this code. I have been trying to modify it to work better for me, but having difficulty.

    My sheet has data from A2:G2280 Column A contains street names. I want to be able to type at least part of the street name into A1 and display only data that contains A1 in all or part. So if I type Bro in A1 I would see the rows that have Broad, Broadway and Brook. Of course if A1 is blank I would see everything.



    Sorry I'm not fluent in the Excel VBA lingo, I'm just a 911 dispatcher that knows their is an easier way.



    Thank you.



    Mark
    • To post as a guest, your comment is unpublished.
      skyyang · 9 months ago
      Hello, Mark,
      To solve your problem, please apply the following VBA code:
      Note: In the below code, the A1 is the cell that you want to enter the criteria, A2:D20 is the data range, A is the column contains the criteria that you want to filter from, please change the cell references to your own.

      Private Sub Worksheet_Change(ByVal Target As Range)
      Dim xRg As Range
      Dim xRRg As Range
      Dim xFNum As Integer
      On Error Resume Next
      If Target.Address <> Range("A1").Address Then Exit Sub
      Set xRg = Range("A2:D20").CurrentRegion
      Application.ScreenUpdating = False
      If Target.Text = "" Then
      xRg.Rows.Select
      Selection.EntireRow.Hidden = False
      Application.ScreenUpdating = True
      Exit Sub
      End If
      For xFNum = 1 To xRg.Rows.Count
      Set xRRg = xRg.Range("A" & xFNum)
      xRRg.Rows.Select
      If InStr(xRRg.Text, Target.Text) > 0 Then
      Selection.EntireRow.Hidden = False
      Else
      Selection.EntireRow.Hidden = True
      End If
      Next xFNum
      Application.ScreenUpdating = True
      End Sub

      Please try it, hope it can help you!
      • To post as a guest, your comment is unpublished.
        Mark · 9 months ago
        Thanks for the help.
        I changed A2:D20 to A3:G2281 to represent my data field. Now when I type anything in cell A1 and tab out of the cell rows 2-109 are hidden. It is not filtering and displaying only rows that contain all or in part what is entered in cell A1.



        Any ideas?
  • To post as a guest, your comment is unpublished.
    shahbaaz · 11 months ago
    its working and awsome...thanks
  • To post as a guest, your comment is unpublished.
    George · 1 years ago
    Thank you for this write up! I am trying to adjust the code to allow a range of acceptance.

    Example: I input 5 and it filters and only shows everything that is within .5 of 5, (so 4.5 to 5.5)
  • To post as a guest, your comment is unpublished.
    Javier · 2 years ago
    Doesn't work for me, might be that I have office 2010? doesn't do anything :S
  • To post as a guest, your comment is unpublished.
    Amanda · 2 years ago
    Hi,

    The code below works perfectly. However, how do I disable the macro if I want to unfilter?
    Private Sub Worksheet_Change(ByVal Target As Range)
    'Updateby Extendoffice 20160606
    If Target.Address = Range("E2").Address Then
    Range("A1:C20").CurrentRegion.AdvancedFilter Action:=xlFilterInPlace, CriteriaRange:=Range("E1:E2")
    End If
    End Sub
    • To post as a guest, your comment is unpublished.
      KST · 1 years ago
      In Range("E2").Address delete any input. All will "unfilter."
  • To post as a guest, your comment is unpublished.
    ZZted · 2 years ago
    How do I undo it?it hides all of my data.
  • To post as a guest, your comment is unpublished.
    jdvdp · 2 years ago
    I've been trying to filter a worksheet with a variety of codes (taken from various sites, including this one), but none seem to work. In a sheet with information in the cell range A101:EF999 (yes, big one), I want to autofilter the sheet based on a three letter code that I enter into cell B5, which should correspond to rows having that same code in column B101-B999. A sample snippet would look like this:

    A B C D E
    5 ABC
    ...
    101 ABC
    102 DEF
    103 GHI
    104 ABC
    105 JKL
    106 ABC
    107 DEF

    On selecting "ABC" in cell B5, only rows 101, 104 and 106 should be displayed, but nothing happens. Is there something I'm overlooking here? Any help would be much appreciated!
  • To post as a guest, your comment is unpublished.
    Jon · 2 years ago
    THANK YOU SO MUCH FOR THE ABOVE FORMULA - IT WORKS GREAT.