View Single Post
 
Old 10-18-2019, 08:09 PM
pike pike is offline Windows 7 64bit Office 2010
Novice
 
Join Date: Jul 2019
Location: Alstonville
Posts: 4
pike is on a distinguished road
Default

maybe his will be more explanatory
Function don't need to ne called and usually return values


Code:
Option Explicit
Dim nrow As Long
Public Function Lastrow() As Long
'Function finding the last row in active worksheet with data
    Lastrow = ActiveSheet.Cells(Rows.Count, 1).End(xlUp).Row
    nrow = Lastrow ' populate nrow
End Function

Public Function Farcol() As String
'Function finding the Far Column in active worksheet with data
    Dim ncol As Long
    ncol = ActiveSheet.UsedRange.Columns.Count
    Farcol = Split(Cells(1, ncol).Address(True, False), "$")(0)
End Function

Sub Display_LastCell()
'Display the last cell with data using Function
    MsgBox "Row = " & Lastrow() & " Column = " & Farcol()
End Sub

Sub Display_nrow()
'Display the last cell with data using nrow variable
    MsgBox "   nrow = " & nrow
End Sub
Reply With Quote