Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #4  
Old 10-18-2019, 06:55 PM
koehlerc14 koehlerc14 is offline Sub vs Function to pass variable or parameter Windows 10 Sub vs Function to pass variable or parameter Office 2016
Novice
Sub vs Function to pass variable or parameter
 
Join Date: Feb 2019
Posts: 6
koehlerc14 is on a distinguished road
Default

Thanks to tips and other threads to lead me to a solution, I'm not entirely sure why it works, but I'm still testing some things out. I'm able to reference it in the Sub. If anyone has any tips to declare parameter from a function to a sub I'd still appreciate it.

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

End Function

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

Farcol = lcol
Sub Macro
Code:
End Function

Sub Display_LastCell()
'Display the last cell with data using Function

Call Lastrow
Call Farcol

MsgBox "Row = " & nrow & " Column = " & Farcol

End Sub
Next is to use as Cell Reference to the range...
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