+ Reply to Thread
Results 1 to 3 of 3

VBA function returning #value in excel

  1. #1
    Registered User
    Join Date
    03-03-2015
    Location
    Toronto
    MS-Off Ver
    2010
    Posts
    2

    VBA function returning #value in excel

    Hi,

    The following function should sort a single column of data.

    If it is run as a subroutine with the following added (wsbubble is the name of the sheet):

    wsBubble.Range("C3:C12") = list

    Then it works and prints out a number.

    However if run as a function in excel (in cells c3:C12 as an array using =bubblesort) it returns a #value error.

    Is there a way to fix this? Or can someone explain why this is not working?

    Thanks in advance!

    edit: forgot to mention, for an example, there is data in cells a2:a10 named "data" in excel.
    The function being used in the cell is =bubblesort(data)



    Here is the function:


    Please Login or Register  to view this content.
    Last edited by mat888; 03-03-2015 at 12:16 PM.

  2. #2
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,436

    Re: VBA function returning #value in excel

    User defined functions can not change cell contents. They can only return values.

    Please Login or Register  to view this content.
    Cheers
    Andy
    www.andypope.info

  3. #3
    Registered User
    Join Date
    03-03-2015
    Location
    Toronto
    MS-Off Ver
    2010
    Posts
    2

    Re: VBA function returning #value in excel

    Thanks so much.

    I thought it would require an extra line setting it to a particular list but I couldn't figure it out for the life of me.

    Mat

+ 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. [SOLVED] Excel function is returning undesired answer for blank cells
    By dcwandj in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 10-28-2012, 12:14 PM
  2. Replies: 1
    Last Post: 09-17-2012, 05:14 AM
  3. Excel 2007 : Excel Function returning 0
    By easdenp in forum Excel General
    Replies: 1
    Last Post: 07-22-2011, 07:52 AM
  4. Excel 2007 If function using 2 worksheets returning formulas
    By kiepre in forum Excel Formulas & Functions
    Replies: 13
    Last Post: 04-01-2009, 08:48 AM
  5. Excel Function returning negative 0
    By ibertram in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 11-12-2005, 10:40 AM

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.6.0 RC 1