+ Reply to Thread
Results 1 to 2 of 2

How to copy an array to excel sheet?

  1. #1
    Registered User
    Join Date
    11-07-2014
    Location
    Ottawa
    MS-Off Ver
    2010
    Posts
    1

    How to copy an array to excel sheet?

    Below is my code. I made a one dimensional array and I want to show all the elements of the array on Excel worksheet. But when I call the function on excel it only returns the last value of the array. How do I make it so that a row with all the values of my array will appear?
    Thanks

    Option Explicit

    Public Function NegF(x, y, m, n, z, T As Double) As Variant

    Dim Array1(4) As Variant
    Dim tot, P, m1, n1 As Double
    m1 = n1 = P = 1
    Dim i, j As Integer
    Dim k As Double

    tot = x + y + m + n + z

    Array1(0) = Kp1(T) - (x ^ 3 * y / (m * n)) * (P / tot) ^ 2
    Array1(1) = Kp2(T) - (x * z / y * n)
    Array1(2) = m1 - m - y - z
    Array1(3) = 2 * n1 + 4 * m1 - 4 * m - 2 * n - 2 * x
    Array1(4) = n1 - n - 2 * z - y

    NegF = Array1

    End Function

  2. #2
    Forum Guru
    Join Date
    03-02-2006
    Location
    Los Angeles, Ca
    MS-Off Ver
    WinXP/MSO2007;Win10/MSO2016
    Posts
    12,612

    Re: How to copy an array to excel sheet?

    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.

    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



    (This thread should receive no further responses until this moderation request is fulfilled, as per Forum Rule 7)
    Ben Van Johnson

+ 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] Macro to use array to copy all rows to a new sheet if a cell is not blank not working
    By capson in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 11-05-2014, 01:13 AM
  2. Replies: 0
    Last Post: 06-28-2014, 02:26 PM
  3. copy entire excell sheet cells values into string array
    By laltoo2405 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 03-03-2014, 09:17 PM
  4. Copy value to Array variables use them in another sheet!
    By ravikiran in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 11-19-2012, 04:15 AM
  5. Copy from one sheet using an array
    By peakymatt in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-12-2009, 09:23 AM

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