+ Reply to Thread
Results 1 to 3 of 3

Writing the Output of Function to sheet2

  1. #1
    Registered User
    Join Date
    07-06-2018
    Location
    India
    MS-Off Ver
    2010
    Posts
    4

    Writing the Output of Function to sheet2

    I have a function written in a module and i call ths function from mutiple rows .I have the Following Function which return a value. I want the value to be written into Sheet2 instead of displaying in the cell from which the function is called

    For every returned value , the output should get written to the next row in sheet2
    Dim curRow As Variant




    Function sellbuy(high, low As Variant) As Variant


    Dim a As Variant
    Dim Totalhigh As Variant
    Dim highmult As Variant
    Dim resulthigh As Variant
    Dim resultlow As Variant
    Dim row As Variant



    resulthigh = high
    resultlow = low
    'result = (high Mod 10) + Int(high / 10)
    curRow = Application.Caller.row

    If resulthigh = 6 Or resulthigh = 20 Then

    'MsgBox "Sell " & "" & Cells(ActiveCell.row, 2)
    sellbuy = "Sell" & " " & Cells(curRow, 2) & " " & "High " & Cells(curRow, 15) & " " & Time


    End If

    If resultlow = 6 Or resultlow = 20 Then

    'MsgBox "Sell " & " " & Cells(ActiveCell.row, 2)
    sellbuy = "Buy" & " " & Cells(curRow, 2) & " " & "Low " & Cells(curRow, 16) & " " & Time

    End If

    End Function

    The Sellbuy value should be written in sheet2 . For every Sellbuy value returned the value must be written in next row of sheet 2
    Last edited by deepak7791; 07-06-2018 at 03:33 PM.

  2. #2
    Forum Expert
    Join Date
    12-14-2012
    Location
    London England
    MS-Off Ver
    MS 365 Office Suite.
    Posts
    8,448

    Re: Writing the Output of Function to sheet2

    I do not think that what you ask is possible.

    Ok I have tested this instruction and various others. It does not work.


    Please Login or Register  to view this content.


    This does not work either:-


    Please Login or Register  to view this content.
    Last edited by mehmetcik; 07-06-2018 at 04:06 PM.
    My General Rules if you want my help. Not aimed at any person in particular:

    1. Please Make Requests not demands, none of us get paid here.

    2. Check back on your post regularly. I will not return to a post after 4 days.
    If it is not important to you then it definitely is not important to me.

  3. #3
    Forum Guru
    Join Date
    04-13-2005
    Location
    North America
    MS-Off Ver
    2002/XP and 2007
    Posts
    15,827

    Re: Writing the Output of Function to sheet2

    A UDF (a function procedure called from a spreadsheet cell) cannot change cells elsewhere in the spreadsheet. It can only return a value to the cell (or cells, if array entered) it is called from.

    If you want the result on sheet2, is there some reason not to enter the UDF on sheet2 where you want the result?

    If there is some reason not to enter the UDF on sheet2, I would probably use a simple =cell containing UDF on sheet2.
    Quote Originally Posted by shg
    Mathematics is the native language of the natural world. Just trying to become literate.

+ 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. Replies: 3
    Last Post: 09-24-2015, 08:20 AM
  2. Matching multiple criteria from Sheet1 in Sheet2 and writing it in Sheet3
    By smgjob in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 07-08-2015, 06:16 PM
  3. [SOLVED] Matching multiple criteria from Sheet1 in Sheet2 and writing it in Sheet3
    By smgjob in forum Tips and Tutorials
    Replies: 4
    Last Post: 07-08-2015, 04:10 AM
  4. [SOLVED] Look for values in sheet1 (input) and paste output in dedicated cells in sheet2
    By dnlwstr in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 01-30-2013, 06:38 AM
  5. Replies: 0
    Last Post: 12-05-2012, 09:59 PM
  6. Input Sheet2 Output Sheet1
    By tomjoe in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 02-25-2008, 02:32 AM
  7. Formula in Sheet1, Output on Sheet2 Sheet 3...
    By uwhuskies in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 07-04-2007, 07:55 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