General Programming Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 



Go Back   Dev Articles Community ForumsProgrammingGeneral Programming Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old October 14th, 2004, 12:09 PM
AccountingFreak AccountingFreak is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Oct 2004
Posts: 3 AccountingFreak User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Angry Run-time error '91': Excel Macro

I've created a macro in Excel and it doesn't seem to handle the errors properly. I get the Run-time error '91': Object variable or With block variable not set. I have two sheets 'Sheet1' has 333 in the 'A1' cell and 4444 in the 'A2' cell. 'Sheet2' is blank. The error handling works for the first number not the second. I'm trying to compare two lists with each other and document the ones that appear in one and not the other.

[
Sub test()
'
' test Macro
'
'
' Local Variables
Dim num As Double
Dim rowWalker As Double

' Variable intialization
num = 11111
rowWalker = 1

Top:
Sheets("Sheet1").Select
Range("A:A").Select

On Error GoTo IfError ' This only works for the 11111 number
' not the 22222 number
Cells.Find(What:=num, After:=ActiveCell, LookIn:=xlFormulas, LookAt _
:=xlPart, SearchOrder:=xlByColumns, SearchDirection:=xlDown, MatchCase:= _
True).Activate
GoTo SkipError ' If found skip error handling

' If in error document it
IfError:
Sheets("Sheet2").Select
Range("A" & rowWalker).Select
ActiveCell = num
Range("B" & rowWalker).Select
ActiveCell = "Not Found"
Sheets("Sheet1").Select
' Go onto the next number
SkipError:
If num = 11111 Then
num = 22222
GoTo Top
End If

End Sub
]

Last edited by AccountingFreak : October 14th, 2004 at 12:11 PM. Reason: Misspelling for clarification

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingGeneral Programming Help > Run-time error '91': Excel Macro


Developer Shed Advertisers and Affiliates


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.

© 2003-2018 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap