You'll need to set up a user-defined function
in a module:
Public Function activecel()
Application.Volatile
' first syntax returns B2
' second syntax returns Sheet1!B2
' activecel = activecell.Address
activecel = activecell.Parent.Name & "!" & activecell.Address
End Function
And... you'll want the following in the
ThisWorkbook module:
Private Sub Workbook_SheetActivate(ByVal Sh As Object)
Sh.Calculate ' prevents a syntax error--go figure
Calculate
End Sub
Private Sub Workbook_SheetSelectionChange(ByVal Sh As Object, ByVal Target As Excel.Range)
Sh.Calculate ' prevents a syntax error--go figure
Calculate
End Sub
If you need something other than the A1-form
of the address, you can modify the activecel
code...
Good luck!
Thanks a lot for the solution. It is a bit more complicated than I thought it would be. I am simply trying to run a loop from the top of my spreadsheet to the last row of data. I wanted to use this function to find the last row without having to set the loop counter higher than needed.
J.R.
If you just need the last row of daat within
VBA, it's *much* easier:
For example see Tony Scala's recent post:
7234.html
that you probably could moficy to meet your needs.
--tim