I need to code a VBA function I can call from a worksheet to get the value of a cell on a different worksheet in the same workbook.
I'm getting a #NAME! error when I try it.
My code looks like this:
Function FindLastValueInA()
r = Worksheets("Amendments Log").UsedRange.Rows.Count
cellref = "$A$" & r
FindLastValueInA = Range(cellref).Value
End Function
and I'm calling this from a cell on a sheet called "Atherstone" using :
=FindLastValueInA
The code is held in a module rather than in ThisWorkbook or any particular sheet.
What am I doing wrong?
Cheers,
Dave
"Yes, I'll stop finding bugs in the software - as soon as you stop writing bugs into the software." <-- Me
For all your testing needs: Forum1393
I'm getting a #NAME! error when I try it.
My code looks like this:
Function FindLastValueInA()
r = Worksheets("Amendments Log").UsedRange.Rows.Count
cellref = "$A$" & r
FindLastValueInA = Range(cellref).Value
End Function
and I'm calling this from a cell on a sheet called "Atherstone" using :
=FindLastValueInA
The code is held in a module rather than in ThisWorkbook or any particular sheet.
What am I doing wrong?
Cheers,
Dave
"Yes, I'll stop finding bugs in the software - as soon as you stop writing bugs into the software." <-- Me
For all your testing needs: Forum1393