Results 1 to 5 of 5

Thread: Array to Excel

  1. #1

    Thread Starter
    New Member
    Join Date
    Jul 2011
    Posts
    8

    Question Array to Excel

    Hello all. I just have a quick question. I have an array that looks like this:

    Dim x() As Integer= {20, 35, 50, 15, 75, 30, 55, 62.5, 15, 40, 40, 62.5, 35, 45, 50, 32.5, 42.5, 20, 47.5, 27.5, 60, 35, 75, 30, 45, 37.5, 25, 37.5, 30, 45}

    I would like for each value of the array to be in its own cell in Microsoft Excel, with the first value, 20, in cell E2, and the final value, 45, in cell E31. How would I go about doing this. I thought that I could do this:

    xSheet.Columns("E2:E31") = {20, 35, 50, 15, 75, 30, 55, 62.5, 15, 40, 40, 62.5, 35, 45, 50, 32.5, 42.5, 20, 47.5, 27.5, 60, 35, 75, 30, 45, 37.5, 25, 37.5, 30, 45}

    But I get an error message each time, so it is probably wrong.

    I have been successful in filling the first 4 columns of the spreadsheet with other arrays, but this is the first array in it that is using values a define before the program begins.

  2. #2
    eXtreme Programmer .paul.'s Avatar
    Join Date
    May 2007
    Location
    Chelmsford UK
    Posts
    25,479

    Re: Array to Excel

    that array isn't integer()

    Code:
    Dim x() As Integer= {20, 35, 50, 15, 75, 30, 55, 62.5, 15, 40, 40, 62.5, 35, 45, 50, 32.5, 42.5, 20, 47.5, 27.5, 60, 35, 75, 30, 45, 37.5, 25, 37.5, 30, 45}

  3. #3

    Thread Starter
    New Member
    Join Date
    Jul 2011
    Posts
    8

    Re: Array to Excel

    So, it should be Decimal right?

    Also, I have another question. I don't know if you know, but do you know how to (you know) graph a curve of best fit on Excel, like a line of best fit, but a curve, preferably a logarithmic curve?
    Last edited by rbrtadlsn; Aug 4th, 2011 at 10:50 AM.

  4. #4
    eXtreme Programmer .paul.'s Avatar
    Join Date
    May 2007
    Location
    Chelmsford UK
    Posts
    25,479

    Re: Array to Excel

    try this:

    vb Code:
    1. Dim x() As Double = {20, 35, 50, 15, 75, 30, 55, 62.5, 15, 40, 40, 62.5, 35, 45, 50, 32.5, 42.5, 20, 47.5, 27.5, 60, 35, 75, 30, 45, 37.5, 25, 37.5, 30, 45}
    2.  
    3. xlWorkSheet.Range("A1:A30").Value = xlApp.WorksheetFunction.Transpose(x)

  5. #5
    eXtreme Programmer .paul.'s Avatar
    Join Date
    May 2007
    Location
    Chelmsford UK
    Posts
    25,479

    Re: Array to Excel

    Quote Originally Posted by rbrtadlsn View Post
    So, it should be Decimal right?

    Also, I have another question. I don't know if you know, but do you know how to (you know) graph a curve of best fit on Excel, like a line of best fit, but a curve, preferably a logarithmic curve?
    Double will work.
    Can't help with the graph. Sorry.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width