![]() |
Excel Macro user function used in several sheets in same workbook
I have created a macro function to reference tha last cell used in a column
and returns the data in it to another cell in the sheet. It works fine for just one sheet within the same workbook. But if I use the function in another sheet, it returns the value from the previous sheet. Can anybody help me solve it so that I can get the value that correspond to each sheet. Below is the code I am using Function UltimaFecha(Fecha As Date, celda As String) As Date Application.Volatile Fecha = Cells(Cells.Rows.Count, celda).End(xlUp).Value UltimaFecha = Fecha End Function |
Excel Macro user function used in several sheets in same workbook
Modify your definition of UltimaFetcha:
UltimaFetcha (new Date,"some text", ThisWorkbook.Sheets("sheetname") Function UltimaFecha(Fecha As Date, celda As String, sheet as WorkSheet) As Date Application.Volatile * Fecha = sheet.Cells(sheet.Cells.Rows.Count, celda).End(xlUp).Value * UltimaFecha = Fecha End Function |
All times are GMT +1. The time now is 12:27 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com