Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Same sub different results

Can anyone tell me why the very same sub gives different results whe
run from the Personal.xls workbook? Here is the code:

Sub VLookUpRange()
Dim rName As Name
Set rName = ThisWorkbook.Names("WhatEver")
End Sub

This sub works fine with all workbooks except Personal.xls.

I get the 'Run time error 1004 - application defined or object-define
error' when I try to run it from Personal.xl

--
Message posted from http://www.ExcelForum.com

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Same sub different results

Perhaps Personal.xls doesn't have a name called 'WhatEver'. This is where
you need error checking, like so

On Error Resum Next
Set rName = ThisWorkbook.Names("WhatEver")
If rName Is Nothing Then
MsgBox "Ooops!"
End If

It is probable that you don't mean ThisWorkbook which is the workbook the
code is in, buty ACtiveWorkbook, which is the one you are working on.

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"DredanZyl " wrote in message
...
Can anyone tell me why the very same sub gives different results when
run from the Personal.xls workbook? Here is the code:

Sub VLookUpRange()
Dim rName As Name
Set rName = ThisWorkbook.Names("WhatEver")
End Sub

This sub works fine with all workbooks except Personal.xls.

I get the 'Run time error 1004 - application defined or object-defined
error' when I try to run it from Personal.xls


---
Message posted from http://www.ExcelForum.com/



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Same sub different results

Thanks William, that was it. I should have put 'Active workbook'.







William wrote:
*Hi DredanZyl

Do you have a defined name called "Whatever" in "Personal.xls" sinc
your
code refers to that name in "ThisWorkbook" which is the workboo
executing
the sub. Do you mean "ActiveWorkbook".

--
XL2002
Regards

William



"DredanZyl " wrote i
message
...
| Can anyone tell me why the very same sub gives different result
when
| run from the Personal.xls workbook? Here is the code:
|
| Sub VLookUpRange()
| Dim rName As Name
| Set rName = ThisWorkbook.Names("WhatEver")
| End Sub
|
| This sub works fine with all workbooks except Personal.xls.
|
| I get the 'Run time error 1004 - application defined o
object-defined
| error' when I try to run it from Personal.xls
|
|
| ---
| Message posted from
http://www.ExcelForum.com/
|


--
Message posted from http://www.ExcelForum.com

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
More MIN() results..? Mac Excel Worksheet Functions 1 October 16th 07 03:52 PM
different results Dave Excel Discussion (Misc queries) 0 January 23rd 07 12:00 AM
Conditional Sum Argument results do not equal cell results Excel Randy R Mullins Excel Worksheet Functions 3 August 9th 06 07:16 PM
min or max results GoofyinNY Excel Worksheet Functions 3 December 23rd 05 03:27 PM
How can I list the results of my macro without overwritng previous results? mattip Excel Programming 3 November 28th 03 03:45 AM


All times are GMT +1. The time now is 10:44 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"