Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Rogerio Takejame
 
Posts: n/a
Default UDF x worksheet functions

I use the UDF below to find the value of the last cell in a certain column.
But I use this function in many worksheets which will be sent do many people.
I want to avoid the attachment of the function in each worksheet and also to
avoide the use of .XLA. Is there a way to have the same results only with
worksheet functions in a way that any standard Excel could calculate?

Function ultima(col As Integer) As Variant
Application.Volatile
If Cells(65536, col) = "" Then
ultima = Cells(65536, col).End(xlUp).Value
Else
ultima = Cells(65536, col).Value
End If
End Function

--
Rogerio Takejame
Americana - Sao Paulo - Brazil
  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
David McRitchie
 
Posts: n/a
Default UDF x worksheet functions

Hi Rogerio,
see http://www.mvps.org/dmcritchie/excel...l.htm#formulas

and your User Defined Function should not be using Integer instead use Long
and instead of 65536 use cells.rows.count
---
HTH,
David McRitchie, Microsoft MVP - Excel [site changed Nov. 2001]
My Excel Pages: http://www.mvps.org/dmcritchie/excel/excel.htm
Search Page: http://www.mvps.org/dmcritchie/excel/search.htm

"Rogerio Takejame" wrote in message
...
I use the UDF below to find the value of the last cell in a certain column.
But I use this function in many worksheets which will be sent do many people.
I want to avoid the attachment of the function in each worksheet and also to
avoide the use of .XLA. Is there a way to have the same results only with
worksheet functions in a way that any standard Excel could calculate?

Function ultima(col As Integer) As Variant
Application.Volatile
If Cells(65536, col) = "" Then
ultima = Cells(65536, col).End(xlUp).Value
Else
ultima = Cells(65536, col).Value
End If
End Function

--
Rogerio Takejame
Americana - Sao Paulo - Brazil



  #3   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Rogerio Takejame
 
Posts: n/a
Default UDF x worksheet functions

Thanks a lot for your answer. It is exactly what I was looking for. It is a
nice solution to use cells.rows.count instead of 65536 even because Excel's
new version will have more than 1 millino rows. But I disagree about defining
col as long instead of integer. col will receive the number of the column
which is between 1 and 256. I could almost use the byte data type (1 byte
storing values from 0 to 255), but it wouldn't work for the last column
(column 256). Using integer data type (2 bytes storing values from -32768 to
32767) I will have no problems and will save memory. Using long data type (4
bytes storing values from -2147483648 to 2147483647) I think I will be
wasting memory.
What do you think about?

Best regards

--
Rogerio Takejame
Americana - Sao Paulo - Brazil


"David McRitchie" wrote:

Hi Rogerio,
see http://www.mvps.org/dmcritchie/excel...l.htm#formulas

and your User Defined Function should not be using Integer instead use Long
and instead of 65536 use cells.rows.count
---
HTH,
David McRitchie, Microsoft MVP - Excel [site changed Nov. 2001]
My Excel Pages: http://www.mvps.org/dmcritchie/excel/excel.htm
Search Page: http://www.mvps.org/dmcritchie/excel/search.htm

"Rogerio Takejame" wrote in message
...
I use the UDF below to find the value of the last cell in a certain column.
But I use this function in many worksheets which will be sent do many people.
I want to avoid the attachment of the function in each worksheet and also to
avoide the use of .XLA. Is there a way to have the same results only with
worksheet functions in a way that any standard Excel could calculate?

Function ultima(col As Integer) As Variant
Application.Volatile
If Cells(65536, col) = "" Then
ultima = Cells(65536, col).End(xlUp).Value
Else
ultima = Cells(65536, col).Value
End If
End Function

--
Rogerio Takejame
Americana - Sao Paulo - Brazil




  #4   Report Post  
Posted to microsoft.public.excel.worksheet.functions
David McRitchie
 
Posts: n/a
Default UDF x worksheet functions

You never know when limits may change, the limit in Excel 12
however on columns is known:
The total number of available columns in Excel
Old Limit: 256 (2^8)
New Limit: 16k (2^14) is 16384 (1 to 16384)

Integer is -32,768 to 32,767 so for Excel 12, you would be okay, but
things could change again in the future.

As far as saving space goes you will save nothing in compiled code,
and in what you see the word INTEGER is longer than the word LONG
and I would not worry about that in a 500K workbook, expecially when
processing INTEGER to convert to LONG will probably take more time.
Unless you actually find something in a Microsoft Blog to indicate that
Integer would be more efficient. There have been postings (not by Microsoft)
indicating that on a Mac Integer was automatically changed to Long.
Your point would be more valid in the definition of the Worksheet Columns.
where you might save some space.

In any case the limit on columns will not be 256 so you would want to
use cells.columns.count instead of 256. So you probably want to
actually use a limit based on usedrange or specialcells.
..

--
---
HTH,
David McRitchie, Microsoft MVP - Excel [site changed Nov. 2001]
My Excel Pages: http://www.mvps.org/dmcritchie/excel/excel.htm
Search Page: http://www.mvps.org/dmcritchie/excel/search.htm

"Rogerio Takejame" <Rogerio wrote in message
...
Thanks a lot for your answer. It is exactly what I was looking for. It is a
nice solution to use cells.rows.count instead of 65536 even because Excel's
new version will have more than 1 millino rows. But I disagree about defining
col as long instead of integer. col will receive the number of the column
which is between 1 and 256. I could almost use the byte data type (1 byte
storing values from 0 to 255), but it wouldn't work for the last column
(column 256). Using integer data type (2 bytes storing values from -32768 to
32767) I will have no problems and will save memory. Using long data type (4
bytes storing values from -2147483648 to 2147483647) I think I will be
wasting memory.
What do you think about?

Best regards

--
Rogerio Takejame
Americana - Sao Paulo - Brazil


"David McRitchie" wrote:

Hi Rogerio,
see
http://www.mvps.org/dmcritchie/excel...l.htm#formulas

and your User Defined Function should not be using Integer instead use Long
and instead of 65536 use cells.rows.count
---
HTH,
David McRitchie, Microsoft MVP - Excel [site changed Nov. 2001]
My Excel Pages: http://www.mvps.org/dmcritchie/excel/excel.htm
Search Page: http://www.mvps.org/dmcritchie/excel/search.htm

"Rogerio Takejame" wrote in message
...
I use the UDF below to find the value of the last cell in a certain column.
But I use this function in many worksheets which will be sent do many people.
I want to avoid the attachment of the function in each worksheet and also to
avoide the use of .XLA. Is there a way to have the same results only with
worksheet functions in a way that any standard Excel could calculate?

Function ultima(col As Integer) As Variant
Application.Volatile
If Cells(65536, col) = "" Then
ultima = Cells(65536, col).End(xlUp).Value
Else
ultima = Cells(65536, col).Value
End If
End Function

--
Rogerio Takejame
Americana - Sao Paulo - Brazil







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
Excel worksheet functions. balanand Excel Worksheet Functions 6 January 2nd 06 10:38 AM
How to get the complete list Excel Worksheet Functions phil Excel Worksheet Functions 1 September 5th 05 01:36 PM
Worksheet functions Nadji New Users to Excel 2 June 10th 05 06:25 PM
Worksheet functions - Ajit11021225 Ajit Munj Excel Discussion (Misc queries) 6 February 12th 05 12:19 AM
Indirect reference from one worksheet to another Bill Sturdevant Excel Worksheet Functions 2 December 17th 04 01:23 PM


All times are GMT +1. The time now is 03:55 PM.

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"