+ Reply to Thread
Results 1 to 5 of 5

insert 1-dimensional vector from VB to worksheet

  1. #1
    Valued Forum Contributor luv2glyd's Avatar
    Join Date
    07-13-2008
    Location
    Seattle, WA, US
    MS-Off Ver
    Excel 2010
    Posts
    679

    Question insert 1-dimensional vector from VB to worksheet

    Trying to insert a vector defined in VB into a worksheet, but not working:

    Please Login or Register  to view this content.
    Also, is there a different syntax for a 2-dimensional one?:

    Please Login or Register  to view this content.
    Thanks
    Last edited by luv2glyd; 01-26-2016 at 03:43 PM.
    You either quit or become really good at it. There are no other choices.

  2. #2
    Forum Guru MarvinP's Avatar
    Join Date
    07-23-2010
    Location
    Woodinville, WA
    MS-Off Ver
    Office 365
    Posts
    16,451

    Re: insert 1-dimensional vector from VB to worksheet

    Hi luv,

    You need to do a:
    Range("A1001:A1036").Value = data_vector(2)
    for any success.

    In your code you have put values into array holes. You need to add the (number) to have a value.

    I think the confusion is from thinking that "data_vector" contains a number. It is the name of an array of numbers defined by the address after "data_vector"

    Think of it like you have a street called Main. You have mailboxes on Main of 1,2,3. You put values into these like Main(1)=21 and Main(2)=47. Now you ask VBA for the value of "Main". VBA is confused as Main is a street and you need to tell it what address you are wanting.

    Hope that all makes sense.
    One test is worth a thousand opinions.
    Click the * Add Reputation below to say thanks.

  3. #3
    Forum Expert skywriter's Avatar
    Join Date
    06-09-2014
    Location
    USA
    MS-Off Ver
    365 Version 2505
    Posts
    2,792

    Re: insert 1-dimensional vector from VB to worksheet

    Unless you have an Option Base 1 statement at the top of your module you would use 35 for a 36 element array.

    Please Login or Register  to view this content.

  4. #4
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,646

    Re: insert 1-dimensional vector from VB to worksheet

    Try using Application.Transpose.
    Please Login or Register  to view this content.
    If posting code please use code tags, see here.

  5. #5
    Valued Forum Contributor luv2glyd's Avatar
    Join Date
    07-13-2008
    Location
    Seattle, WA, US
    MS-Off Ver
    Excel 2010
    Posts
    679

    Re: insert 1-dimensional vector from VB to worksheet

    Great! Thanks everyone for quick replies. Had no idea the first row is row #0.

+ 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. Replies: 4
    Last Post: 12-21-2012, 02:56 PM
  2. Replies: 7
    Last Post: 09-22-2011, 11:06 AM
  3. Lookup vector - result vector
    By abousetta in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 08-23-2011, 02:59 AM
  4. Insert an array in a 1-dimensional function
    By Numerator in forum Excel General
    Replies: 2
    Last Post: 11-13-2010, 07:46 PM
  5. Create shorter vector from a vector of unknown length
    By agentred in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 04-15-2010, 12:53 PM
  6. Creating a 2-dimensional array from a 1-dimensional list
    By guywithcamera in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 11-27-2008, 06:34 PM
  7. Replies: 0
    Last Post: 04-05-2006, 02:35 AM
  8. [SOLVED] Insert row for each different value in a vector
    By Alex St-Pierre in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 02-23-2006, 04:55 PM

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