Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 40
Default Run-time error 91

Run-time error 91
Object variable or With block not set

I keep getting the above error when the 2nd line of code runs. I dont
know why. I dont know if this helps but I had to use the InStr
function in order to quit getting an error in the 1st line of code.


FoundCommentCode = Trim(Left(ActiveCell.Value, InStr(ActiveCell.Value,
":") - 1))


TargetCommentCodeAddress =
Worksheets("Questionnaire").Range("P1:P2000").Find (FoundCommentCode).Address


Also I dont know if this will help but here is some other info:
This problem code is in a module in a a public sub that is called from
a Worksheet_SelectionChange precedure in the worksheet module.



Thanks in advance
Todd

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,173
Default Run-time error 91

Todd

Find returns a range object so you will need to declare your variable
TargetCommentCodeAddress as range and then 'Set' it, which you must do for
any object. The address variable needs to be declared as a string, say
AddStr

Set
TargetCommentCodeAddress=Worksheets("Questionnaire ").Range("P1:P2000").Find(FoundCommentCode)

Then you can get the address by using

AddStr=TargetCommentCodeAddress.Address

You may find that you also need to check if anything is found by using

If Not
TargetCommentCodeAddress=Worksheets("Questionnaire ").Range("P1:P2000").Find(FoundCommentCode)
Is Nothing then
AddStr=TargetCommentCodeAddress.Address
End If

--
HTH
Nick Hodge
Microsoft MVP - Excel
Southampton, England
www.nickhodge.co.uk


"Todd Huttenstine" wrote in message
ups.com...
Run-time error 91
Object variable or With block not set

I keep getting the above error when the 2nd line of code runs. I dont
know why. I dont know if this helps but I had to use the InStr
function in order to quit getting an error in the 1st line of code.


FoundCommentCode = Trim(Left(ActiveCell.Value, InStr(ActiveCell.Value,
":") - 1))


TargetCommentCodeAddress =
Worksheets("Questionnaire").Range("P1:P2000").Find (FoundCommentCode).Address


Also I dont know if this will help but here is some other info:
This problem code is in a module in a a public sub that is called from
a Worksheet_SelectionChange precedure in the worksheet module.



Thanks in advance
Todd



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 40
Default Run-time error 91

Nevermind, I finally found out what it was. I had formulas in the
cells in Column P instead of real values. I change the formulas to
values and it worked.

Reply
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
Visual Basic Error Run Time Error, Type Mismatch Meg Partridge Excel Discussion (Misc queries) 12 September 10th 08 06:10 PM
run-time error '1004': Application-defined or object-deifined error [email protected] Excel Programming 5 August 10th 05 09:39 PM
Befuddled with For Next Loop ------ Run - Time Error '13' Type Mismatch Error rdavis7408 Excel Programming 1 August 25th 04 03:54 AM
Code Error - Run Time Error 5 (Disable Cut, Copy & Paste) Tim[_36_] Excel Programming 4 April 23rd 04 02:53 AM
Run-time error '11' & Run-time error '1004' Piers Clinton-Tarestad Excel Programming 0 January 9th 04 08:35 PM


All times are GMT +1. The time now is 09:32 AM.

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

About Us

"It's about Microsoft Excel"