Wrox Programmer Forums
|
Excel VBA Discuss using VBA for Excel programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Excel VBA section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old April 3rd, 2008, 11:01 AM
Registered User
 
Join Date: Apr 2008
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Error 91

Question: Executing the following code, I get the error 91:

Sub Test
    Z = "D" & Cells.Find(What:="Total").Row
End Sub

 
Old April 4th, 2008, 12:31 AM
Authorized User
 
Join Date: Mar 2008
Posts: 74
Thanks: 2
Thanked 0 Times in 0 Posts
Send a message via ICQ to sektor
Default

What is the aim of this code?

 
Old April 4th, 2008, 12:56 AM
Friend of Wrox
 
Join Date: Sep 2005
Posts: 812
Thanks: 1
Thanked 53 Times in 49 Posts
Default

The error comes when there is no 'Total' in the sheet or range

You can avoid that by using the following

Sub Test()
    Set rFnd = Cells.Find(What:="Total")
    If Not rFnd Is Nothing Then
        z = rFnd.Row
    End If
End Sub


Cheers
Shasur

http://www.dotnetdud.blogspot.com

VBA Tips & Tricks (http://www.vbadud.blogspot.com)





Similar Threads
Thread Thread Starter Forum Replies Last Post
error 91 skrj02 Excel VBA 4 May 7th, 2007 11:01 AM
error 91 issues. kd8con Beginning VB 6 1 October 30th, 2006 09:50 AM
Runtime error 91: Apjong Beginning VB 6 1 June 7th, 2006 09:47 AM
runtime error 91 Perseus Beginning VB 6 2 July 30th, 2005 04:36 AM
NTSVC.OCX and Error = 91 skhan22 Pro VB 6 3 October 24th, 2003 01:18 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.