Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Search cells code not working
I have a workbook with 5 worksheets. I was trying to execute code
that will search each worksheet for a specifically entered unique number. If it doesn't find it on the first worksheet, it moves on to the next until it finds it, or it yields a messagae stating the number was not found. I've pulled the code together from a couple different posts here, because my original attempt was yielding me the "Object variable or with block variable not set" error message. The code below runs, but it doesn't seem to find the number or return the row that number is on. Any ideas? Thanks. Dim myNumber as String Dim myWorksheet as Worksheet Dim myRange as Range On Error Resume Next For Each myWorksheet in ActiveWorkbook.Worksheets myRange = Cells.Find(What:=myNumber, After:= _ ActiveCell, LookIn:=x1Values, _ SearchOrder:=x1ByColumns) If Not myRange Is Nothing Then myRow = myRange.Row Else myRow = 0 End If Next myWorksheet If myRow = 0 Then MsgBox("Number not found") |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
format cells as zip code not working | Excel Discussion (Misc queries) | |||
Search for value move to next column code not working | Excel Programming | |||
email from cells to outlook - code not working | Excel Programming | |||
Excel XP VBA code to search all macro code in Excel module for specific search string criteria | Excel Programming | |||
Excel XP VBA code to search all macro code in Excel module for specific search string criteria | Excel Programming |