+ Reply to Thread
Results 1 to 3 of 3

Thread: VBA function to change multiple cell values?

  1. #1
    Registered User
    Join Date
    06-22-2010
    Location
    Rochester
    MS-Off Ver
    Excel 2003
    Posts
    1

    VBA function to change multiple cell values?

    In each row of a spreadsheet, I need to simultaneously calculate three different values based on values in that row. A UDF seems like the proper way to go, something like =MYFunc(a,b,c). However, a function can only return a single value. I have "solved" my problem in an inelegant way, namely =MyFunc1(a,b,c), Myfunc2(a,b,c), Myfunc3(a,b,c), where each function is in its own column/cell. There must be a simpler way! To be clearer, the arguments a,b,c are not the values that are calculated by the function. I need to do this in multiple rows.
    Any suggestions are welcome. Thanks in advance.
    Last edited by Econdoc1; 06-23-2010 at 07:37 AM. Reason: Request by Forum manager

  2. #2
    Forum Guru shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2007, 2010
    Posts
    25,777

    Re: Newbie VBA function question

    Welcome to the forum.

    Please take a few minutes to read the forum rules, and then amend your thread title accordingly.

    Thanks.
    Microsoft MVP - Excel
    Entia non sunt multiplicanda sine necessitate

  3. #3
    Forum Guru Bob Phillips's Avatar
    Join Date
    09-03-2005
    Location
    Wessex
    MS-Off Ver
    MS Excel 2010
    Posts
    2,252

    Re: Newbie VBA function question

    You could return an array, something like

    Public Function myFunc()
    
        myFunc = Array(1, 2, 3)
        
    End Function
    SO you select three cells, say M1,N1 and O1, enter =MyFunc() in the formula bar, and array enter it.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Tags for this Thread

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.2.0