Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Greetings, I have a function that adds two ranges then subtracts Range B from
Range A giving me "N" I would like to know how to modify the following to be able to pass N back into a sub procedure on a userform. Function GetBalances() Dim x As Long, y As Long, N As Long Dim ARange As Range, BRange As Range Set ARange = Range("A:A") Set BRange = Range("B:B") x = WorksheetFunction.Sum(ARange) y = WorksheetFunction.Sum(BRange) N = x - y Debug.Print N End Function |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Sub Test()
MsgBox GetBalances End Sub Function GetBalances() As Long Dim x As Long, y As Long, N As Long Dim ARange As Range, BRange As Range Set ARange = Range("A:A") Set BRange = Range("B:B") x = WorksheetFunction.Sum(ARange) y = WorksheetFunction.Sum(BRange) N = x - y GetBalances = N End Function HTH, Bernie MS Excel MVP "Office_Novice" wrote in message ... Greetings, I have a function that adds two ranges then subtracts Range B from Range A giving me "N" I would like to know how to modify the following to be able to pass N back into a sub procedure on a userform. Function GetBalances() Dim x As Long, y As Long, N As Long Dim ARange As Range, BRange As Range Set ARange = Range("A:A") Set BRange = Range("B:B") x = WorksheetFunction.Sum(ARange) y = WorksheetFunction.Sum(BRange) N = x - y Debug.Print N End Function |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
General Question regarding passing cells, ranges, cell values through subs & functions | Excel Programming | |||
General Question regarding passing cells, ranges, cell values through subs & functions | Excel Programming | |||
General Question regarding passing cells, ranges, cell values through subs & functions | Excel Programming | |||
General Question regarding passing cells, ranges, cell values through subs & functions | Excel Programming | |||
Question: Macro overloading, passing variable number of arguments | Excel Programming |