loop to get list of values that have a partial match

Michael Ziegler

New Member
Joined
Jul 2, 2019
Messages
8
I'm trying to get a list of the content of all the cells that are partial match to to a specific range find but is not working. Here is my code snippet

Option Explicit


Sub OpenXcl()


Dim AppExcel As Object

Dim NetWorkbook As Excel.Workbook

Dim NetWrksht As Excel.Worksheet

Dim vsoShape As Visio.Shape

Dim DiagramServices As Integer

Set AppExcel = CreateObject("Excel.application")

AppExcel.Workbooks.Open "C:\Users\michael\Documents\Working.xlsx"
AppExcel.Visible = True


Dim rngToSearch As Variant
Dim selectedCell As Range


Dim WhatToFind As Variant


WhatToFind = Array("boston", "gordon", "housatonic", "barb")


Set rngToSearch = Range("A:A").Find(What:=WhatToFind, LookIn:=xlValues, Lookat:=xlPart)


For Each NetWrksht In ActiveWorkbook.Worksheets


If Not rngToSearch Is Nothing Then



MsgBox rngToSearch


Else

MsgBox "End"

End If

Next

ActiveWorkbook.Close SaveChanges:=False



End Sub
 

Excel Facts

What did Pito Salas invent?
Pito Salas, working for Lotus, popularized what would become to be pivot tables. It was released as Lotus Improv in 1989.

Forum statistics

Threads
1,215,062
Messages
6,122,925
Members
449,094
Latest member
teemeren

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top