Results 1 to 12 of 12

Writing into Excel worksheet from custom VBA function (not sub)

Threaded View

  1. #1
    Registered User
    Join Date
    12-24-2013
    Location
    Houston, TX
    MS-Off Ver
    Excel 2010
    Posts
    6

    Question Writing into Excel worksheet from custom VBA function (not sub)

    0 down vote favorite
    1


    I would greatly appreciate your assistance in helping me write data from a custom VBA function into an excel worksheet. I have been able to write from a custom VBA subroutine but get an error whilst executing a VBA function. In the sample code, "Sub write 2" and "Sub write 3" work just fine. But "Function test 2()" generates "Value!" in its cell and write3 isn't executed.

    Sub write2(r As Integer, c As Integer, d As Double)
        Dim a, b As Integer
        For a = r To r + 1
            For b = c To c + 1
                Cells(a, b).Value = d
            Next b
        Next a
    End Sub
    
    Sub write3()
        Call write2(3, 60, 0.437)
    End Sub
    
    Function test2() As Double
        Call write3
        test2 = 1#
    End Function
    Last edited by Leith Ross; 12-24-2013 at 10:51 PM. Reason: Added Code tags

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. How do I run a custom function only when a worksheet is selected?
    By jack.x in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 06-18-2012, 01:59 AM
  2. Worksheet as custom function?
    By burro in forum Excel General
    Replies: 3
    Last Post: 11-10-2011, 08:14 PM
  3. Custom Function from worksheet result
    By tJasC3 in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 06-04-2008, 04:24 AM
  4. add worksheet in custom function
    By djoella in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 07-10-2007, 05:53 PM
  5. Activate a Worksheet from a Custom Function ??
    By monir in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 05-17-2005, 02:06 PM

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