![]() |
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 |
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 |
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 |
All times are GMT +1. The time now is 05:53 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com