vendredi 27 mars 2015

vba access function for extract cell value

I'm trying to write a function for extract cell string value of the first previous valorized cell of a certain column.


I try to explain better: I've a column in witch not all cells cointans values. So if I want to build a function that accept as parameter 1 cell, e.g. 'A5'. If into A5 cell there is not any value it check if previous cell (A4) has some value. If fails again it recursively go back (A3..A2..A1) until it find something.



Public Function getPreviousValorizedCellValue(ByVal cell As Range) As String
If (cell.Value = "") Then
Set cell = cell.Offset(-1, 0)
getPreviousValorizedCellValue (cell)
Else: getPreviousValorizedCellValue = cell.Value
End If
End Function


It doesnt work. Excel give me error


Any ideas?


Aucun commentaire:

Enregistrer un commentaire