+ Reply to Thread
Results 1 to 2 of 2

Nested functions

  1. #1
    Registered User
    Join Date
    11-05-2017
    Location
    india
    MS-Off Ver
    2010
    Posts
    2

    Nested functions

    Hi ,

    Can someone tell me why I'm getting 45 as my intuition says it should be 55 instead because of nested functionality...

    Option Explicit
    Dim z As Integer
    Sub Question13()
    Dim x As Integer, total As Integer
    x = 25
    z = 10
    total = AddTwo1(x) + z
    MsgBox "O/P from Main :" & total
    'MsgBox "O/P from AddTwo1 call :" & AddTwo1(x)

    End Sub

    Function AddTwo1(x As Integer) As Integer
    Dim z As Integer
    AddTwo1 = AddTwo2(x) + z
    'MsgBox "O/P from AddTwo2 call :" & AddTwo2(x)
    'MsgBox "O/P from AddTwo1 function :" & AddTwo1
    End Function



    Function AddTwo2(x As Integer) As Integer
    AddTwo2 = x + z
    ' MsgBox "O/P from AddTwo2 function :" & AddTwo2
    End Function

  2. #2
    Forum Expert
    Join Date
    08-12-2012
    Location
    Sydney, Australia
    MS-Off Ver
    Excel 2010
    Posts
    5,636

    Re: Nested functions

    Your post does not comply with Rule 3 of our Forum RULES. Use code tags around code.

    Posting code between [CODE]Please [url=https://www.excelforum.com/login.php]Login or Register [/url] to view this content.[/CODE] tags makes your code much easier to read and copy for testing, it also maintains VBA formatting.

    Click on Edit to open your thread, then highlight your code and click the # icon at the top of your post window. More information about these and other tags can be found here
    If you are satisfied with the solution(s) provided, please mark your thread as Solved.
    Select Thread Tools-> Mark thread as Solved. To undo, select Thread Tools-> Mark thread as Unsolved.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Nested functions
    By tayloratwood in forum Excel Formulas & Functions
    Replies: 12
    Last Post: 04-03-2017, 12:13 AM
  2. [SOLVED] Nested IF functions
    By Darko_Giac in forum Excel General
    Replies: 3
    Last Post: 01-05-2016, 03:17 PM
  3. Nested IF functions
    By Tulsip in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 11-23-2015, 03:02 AM
  4. Replies: 6
    Last Post: 03-17-2015, 01:35 AM
  5. Nested IF Functions
    By stephen1000 in forum Excel General
    Replies: 27
    Last Post: 12-17-2008, 05:44 PM
  6. [SOLVED] Nested IF and MID functions
    By Bob Phillips in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 09-06-2005, 04:05 AM
  7. [SOLVED] Nested IF and MID functions
    By Jan Buckley in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 09-05-2005, 10:05 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1