Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default USer Defined Function


Dear All,

I have the following user defined function in a workbook (taken from a
reply to an earlier post I made)

Public Function Findlastcell(MyAddress As Range)

Application.Volatile
Findlastcell = Cells(MyAddress.Row, 256).End(xlToLeft).Value

End Function

It works perfectly well in lets say file1.xls until I open another file
(file2.xls).

The formula then takes the values from file2.xls. I can rectify this by
going back to file1.xls and then pressing F9.

How do I make the code above specific to file1.xls only.

Excel Dummy.


------------------------------------------------
~~ Message posted from http://www.ExcelTip.com/
~~View and post usenet messages directly from http://www.ExcelForum.com/

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 968
Default USer Defined Function

To extend Chip's solution to the case where MyAddress is not on the same
sheet as the cell the function is called from it probably should be:

Findlastcell = MyAddress.Parent.Cells(MyAddress.Row,256).End(xlTo Left).Value

regds
Charles
______________________
Decision Models
The Excel Calculation Site
www.DecisionModels.com

"Chip Pearson" wrote in message
...
Change
Findlastcell = Cells(MyAddress.Row, 256).End(xlToLeft).Value
to
Findlastcell = Application.Caller.Parent.Cells(MyAddress.Row,
256).End(xlToLeft).Value


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com

"Excel Dummy" wrote in message
...

Dear All,

I have the following user defined function in a workbook (taken from a
reply to an earlier post I made)

Public Function Findlastcell(MyAddress As Range)

Application.Volatile
Findlastcell = Cells(MyAddress.Row, 256).End(xlToLeft).Value

End Function

It works perfectly well in lets say file1.xls until I open another file
(file2.xls).

The formula then takes the values from file2.xls. I can rectify this by
going back to file1.xls and then pressing F9.

How do I make the code above specific to file1.xls only.

Excel Dummy.


------------------------------------------------
~~ Message posted from
http://www.ExcelTip.com/
~~View and post usenet messages directly 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
user defined function tom_mcd Excel Worksheet Functions 1 January 6th 09 06:23 PM
User Defined function - Help makulski Excel Worksheet Functions 8 February 27th 08 09:44 PM
user defined function ub Excel Worksheet Functions 6 April 4th 07 09:42 PM
user defined function Brian Rogge Excel Worksheet Functions 5 May 23rd 05 06:21 PM
User-defined function PierreL Excel Worksheet Functions 4 December 23rd 04 09:16 AM


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