View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
TarrynG TarrynG is offline
external usenet poster
 
Posts: 6
Default UDF won't refresh - please help

Hello

I have a UDF to get the contents of the last cell in a column where those
contents are a number and not "". I first find the last cell which typically
will contain a formula but have it's value set to "" and then 'count back'
until I hit a cell which has a number.

My function works, but when I run a sub to refresh other calculations on my
sheet, my UDF does not refresh and #VALUE! occurs. Any help will be greatly
appreciated.

Thanks
Tarryn

My Function:

Function LASTCELL(input_range As Range, n As Integer)
Application.Volatile True

col_number = input_range.Column

last_row = Cells(Rows.Count, col_number).End(xlUp).Row

Do Until Application.WorksheetFunction.IsNumber(Cells(last_ row,
col_number).Value)

last_row = last_row - 1

Loop

LASTCELL = Cells(last_row - n, col_number)