메인 컨텐츠로 가기

Google 검색 결과를 Excel의 워크 시트에 채우는 방법은 무엇입니까?

경우에 따라 Google에서 중요한 키워드 검색을 수행하고 기사의 제목과 하이퍼 링크가 포함 된 워크 시트에 상위 검색 결과 기록을 유지해야 할 수도 있습니다. 이 기사에서는 셀의 주어진 키워드를 기반으로 Google 검색 결과를 워크 시트에 채우는 데 도움이되는 VBA 방법을 제공합니다.

Google 검색 결과를 VBA 코드로 워크 시트에 채우기


Google 검색 결과를 VBA 코드로 워크 시트에 채우기

아래 스크린 샷과 같이 A 열의 목록을 검색하는 데 필요한 키워드를 가정하면 다음과 같이 이러한 키워드의 Google 검색 결과를 VBA 코드로 해당 열에 채우십시오.

1. 누르세요 다른 + F11 키를 눌러 응용 프로그램 용 Microsoft Visual Basic 창.

2. 에서 응용 프로그램 용 Microsoft Visual Basic 창을 클릭하십시오 끼워 넣다 > 모듈. 그런 다음 VBA 코드를 코드 창에 복사하여 붙여 넣습니다.

VBA 코드 : 워크 시트에 Google 검색 결과 채우기

Sub xmlHttp()
'Updated by Extendoffice 2018/1/30
    Dim xRg As Range
    Dim url As String
    Dim xRtnStr As String
    Dim I As Long, xLastRow As Long
    Dim xmlHttp As Object, xHtml As Object, xHtmlLink As Object
    On Error Resume Next
    Set xRg = Application.InputBox("Please select the keywords you will search in Google:", "KuTools for Excel", Selection.Address, , , , , 8)
    If xRg Is Nothing Then Exit Sub
    Application.ScreenUpdating = False
    xLastRow = xRg.Rows.Count
    Set xRg = xRg(1)
    For I = 0 To xLastRow - 1
        url = "https://www.google.co.in/search?q=" & xRg.Offset(I) & "&rnd=" & WorksheetFunction.RandBetween(1, 10000)
        Set xmlHttp = CreateObject("MSXML2.serverXMLHTTP")
        xmlHttp.Open "GET", url, False
        xmlHttp.setRequestHeader "Content-Type", "text/xml"
        xmlHttp.setRequestHeader "User-Agent", "Mozilla/5.0 (Windows NT 6.1; rv:25.0) Gecko/20100101 Firefox/25.0"
        xmlHttp.send
        Set xHtml = CreateObject("htmlfile")
        xHtml.body.innerHTML = xmlHttp.ResponseText
        Set xHtmlLink = xHtml.getelementbyid("rso").getelementsbytagname("H3")(0).getelementsbytagname("a")(0)
        xRtnStr = Replace(xHtmlLink.innerHTML, "<EM>", "")
        xRtnStr = Replace(xRtnStr, "</EM>", "")
        xRg.Offset(I, 1).Value = xRtnStr
        xRg.Offset(I, 2).Value = xHtmlLink.href
    Next
    Application.ScreenUpdating = True
End Sub

3. 누르세요 F5 코드를 실행하는 키입니다. 팝업에서 Excel 용 Kutools 대화 상자에서 검색할 키워드가 포함된 셀을 선택한 다음 OK 단추. 스크린 샷보기 :

그런 다음 제목과 링크를 포함한 모든 검색 결과가 키워드를 기반으로 해당 열 셀에 채워집니다. 스크린샷 보기:


관련 기사 :

최고의 사무 생산성 도구

🤖 Kutools AI 보좌관: 다음을 기반으로 데이터 분석을 혁신합니다. 지능형 실행   |  코드 생성  |  사용자 정의 수식 만들기  |  데이터 분석 및 차트 생성  |  Kutools 기능 호출...
인기 기능: 중복 항목 찾기, 강조 표시 또는 식별   |  빈 행 삭제   |  데이터 손실 없이 열이나 셀 결합   |   수식없이 반올림 ...
슈퍼 조회: 다중 기준 VLookup    다중 값 VLookup  |   여러 시트에 걸친 VLookup   |   퍼지 조회 ....
고급 드롭다운 목록: 드롭다운 목록을 빠르게 생성   |  종속 드롭다운 목록   |  다중 선택 드롭 다운 목록 ....
열 관리자: 특정 개수의 열 추가  |  열 이동  |  Toggle 숨겨진 열의 가시성 상태  |  범위 및 열 비교 ...
특색 지어진 특징: 그리드 포커스   |  디자인보기   |   큰 수식 바    통합 문서 및 시트 관리자   |  리소스 라이브러리 (자동 텍스트)   |  날짜 선택기   |  워크 시트 결합   |  셀 암호화/해독    목록으로 이메일 보내기   |  슈퍼 필터   |   특수 필터 (굵게/기울임꼴/취소선 필터링...) ...
상위 15개 도구 세트12 본문 도구 (텍스트 추가, 문자 제거,...)   |   50+ 거래차트 유형 (Gantt 차트,...)   |   40+ 실용 방식 (생일을 기준으로 나이 계산,...)   |   19 삽입 도구 (QR 코드 삽입, 경로에서 그림 삽입,...)   |   12 매출 상승 도구 (숫자를 단어로, 환율,...)   |   7 병합 및 분할 도구 (고급 결합 행, 셀 분할,...)   |   ... 그리고 더

Excel용 Kutools로 Excel 기술을 강화하고 이전과는 전혀 다른 효율성을 경험해 보세요. Excel용 Kutools는 생산성을 높이고 시간을 절약하기 위해 300개 이상의 고급 기능을 제공합니다.  가장 필요한 기능을 얻으려면 여기를 클릭하십시오...

상품 설명


Office Tab은 Office에 탭 인터페이스를 제공하여 작업을 훨씬 쉽게 만듭니다.

  • Word, Excel, PowerPoint에서 탭 편집 및 읽기 사용, Publisher, Access, Visio 및 Project.
  • 새 창이 아닌 동일한 창의 새 탭에서 여러 문서를 열고 만듭니다.
  • 생산성을 50% 높이고 매일 수백 번의 마우스 클릭을 줄입니다!
Comments (6)
No ratings yet. Be the first to rate!
This comment was minimized by the moderator on the site
This code requires you to buy and download Kutools to make this code run successfully. Has anyone found an option without the Kutools add-in?
This comment was minimized by the moderator on the site
Hi Mat,There is no relationship between Kutools and the code. You don't need to download or buy Kutools, just apply the code step-by-step as mentioned in the post.
This comment was minimized by the moderator on the site
Hi Crystal

Sorry but I got an "Object Variable not set" on line 24
This comment was minimized by the moderator on the site
The same here.

I follow the code, by copy it then paste the code in Excel VBA module. But after running, nothing happen, column B and C still empty but there is no error though.
This comment was minimized by the moderator on the site
Hi, I've followed the points to be able to pull information from a google search based on keywords and it's not bringing any results though, I've emailed support and I've been advised to put a post here because they can't help me.
This comment was minimized by the moderator on the site
I have not been able to pull anything from google either. I followed instructions exactly.
There are no comments posted here yet
Please leave your comments in English
Posting as Guest
×
Rate this post:
0   Characters
Suggested Locations