+ Reply to Thread
Results 1 to 3 of 3

Pasting Array information to new worksheet

  1. #1
    Registered User
    Join Date
    08-02-2012
    Location
    Dallas, Texas
    MS-Off Ver
    Excel 2007
    Posts
    44

    Pasting Array information to new worksheet

    I must rely on those more fluent in VBA and array manipulation than moi.
    For the life of me I'm stuck.

    I am placing into an array columns A, B, and D, NOT C.
    Appears this must be done with a union - if not let me know.
    Yes, have Dim myData as Variant

    Set facilityID = Wks.Range("A:B")
    Set triChemical = Wks.Range("D:D")

    myData = Union(facilityID, triChemical)

    In column C is a year. I use an inputbox to tell Excel which year I want data for, e.g., 2014.

    I use an If statement to test the year, i.e., variable name YeatToInput

    'Test the to see which year to extract data
    If bigArray(i, 3) = YearToInput Then
    Worksheets(NewWorkSheetName).Range("A1:C3").Resize(UBound(myData, 2)).Value = myData
    Worksheets(NewWorkSheetName).Columns("A:C").AutoFit

    A new worksheet is generated and some data is pasted to the worksheet, but the last column ends up #NA, I have no clue why?

    Output example:

    Col A Col B Col C

    88330HLLMNHWY70 US DOD USAF HOLLOMAN AFB #N/A
    88330HLLMNHWY70 US DOD USAF HOLLOMAN AFB #N/A

    Also, there should in fact be 3 rows of data not 2.

    Suggestions on correct way to output would be appreciated.

    Help an ole Vet on Veterans Day - smile.
    Thanks,
    Mort

  2. #2
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,643

    Re: Pasting Array information to new worksheet

    It's kind of hard to follow what you're describing. Is bigArray the data from the range myData? If yes, you can't read data into an array from a noncontiguous range by using the syntax; Array = noncontiguous_range.Value
    Is that what you did?

    Otherwise, I'm quite lost as to what you're describing. Do you have an example workbook you can post?
    Surround your VBA code with CODE tags e.g.;
    [CODE]your VBA code here[/CODE]
    The # button in the forum editor will apply CODE tags around your selected text.

  3. #3
    Registered User
    Join Date
    08-02-2012
    Location
    Dallas, Texas
    MS-Off Ver
    Excel 2007
    Posts
    44

    Re: Pasting Array information to new worksheet

    Thanks you AlphaFrog!! I so agree that 99% of the problems with communicating in writing is EFFECTIVELY EXPLAINING THE ISSUE.
    My issue has been finally resolved and I would like to post the code...ahhh now I see the code tag icon.

    I had a long list of data occupying columns A through F, 40,000 rows long. "Regular VBA Looping Code" took about 5 minutes to run - LONG TIME!!

    I simply wanted to use an array to read all the data in from the main worksheet, then extract only columns A, B, C, when condition in column D was met (here it was a year)

    An InputBox was used to name the year one wanted to extract, as well as the new worksheet name the extracted data would be copied to.
    I have a "smattering" of comments throughout the code so hopefully it will be much easier to decipher? Hope you find useful?

    Please Login or Register  to view this content.

+ 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: 1
    Last Post: 06-16-2015, 12:28 PM
  2. Copy and pasting information from web
    By welchy82 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 12-19-2014, 04:07 PM
  3. help assigning elements of dictionary to array and then pasting array into worksheet
    By welchs101 in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 12-05-2013, 10:37 AM
  4. [SOLVED] formatting issues pasting date from array to column in worksheet
    By welchs101 in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 04-05-2013, 10:42 AM
  5. Replies: 0
    Last Post: 02-04-2013, 02:28 PM
  6. pasting array from VBA into worksheet
    By twd000 in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 06-09-2010, 05:36 PM
  7. UserForm and Pasting Information
    By Sargon in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 01-22-2008, 12:27 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