Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #5  
Old 10-18-2019, 08:09 PM
pike pike is offline Sub vs Function to pass variable or parameter Windows 7 64bit Sub vs Function to pass variable or parameter 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
 

Tags
functions, parameters



Similar Threads
Thread Thread Starter Forum Replies Last Post
Pass Arguments to Function Through Ribbon inagalaxyfarfarawry Word VBA 11 03-25-2022 09:28 PM
Repeat Function By Changing One Variable abbani Excel 3 10-04-2017 12:41 AM
How can I pass a field as a parameter via a URL? kelvinlewisuk1 Outlook 0 06-30-2016 08:30 AM
Sub vs Function to pass variable or parameter Can a function or sub be called using a variable name? omahadivision Excel Programming 18 12-05-2013 08:14 PM
Sub vs Function to pass variable or parameter Can pass .expression as a parameter? tinfanide PowerPoint 4 12-28-2012 06:14 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 09:49 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft