LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 19
Default Code runs in XL97 but not 2000?

The following code finds the search string in any worksheet of the current
workbook. It works in XL97, but crashes in XL2000 with "Run time error '13':
Type mismatch".

Why is this? When I go to debug it, the editor is opened at this line:

Set sh = ActiveSheet


Dim i As Integer, sh As Worksheet
Dim MyFind As Range
Application.ScreenUpdating = False
Set sh = ActiveSheet
Dim Message, Title, MyValue
Message = "Enter item number"
Title = "Search Item"
MyValue = InputBox(Message, Title, Default)
For i = 1 To Sheets.Count
Sheets(i).Select
Set MyFind = Cells.Find(What:=MyValue)
If Not MyFind Is Nothing Then
Cells.Find(What:=MyValue).Activate
Application.ScreenUpdating = True
Exit Sub
End If
Next i
MsgBox "Item not found, search again"
sh.Activate
Application.ScreenUpdating = True
End Sub




 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
vba code runs...need spaces ........ Wanna Learn Excel Discussion (Misc queries) 2 January 20th 09 12:44 PM
Office 2000 Excel Macro runs very slow in 2003, why? The_Other_Mike Excel Discussion (Misc queries) 1 May 10th 06 04:36 PM
Code runs different in a commandbutton than a macro why? Neal Miller Excel Programming 7 December 7th 03 02:41 AM
Code runs every other time Mike Waldron Excel Programming 1 September 27th 03 03:54 PM
How to keep from going dizzy when my code runs TBA[_2_] Excel Programming 3 September 23rd 03 11:33 PM


All times are GMT +1. The time now is 04:34 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"