+ Reply to Thread
Results 1 to 7 of 7

Pasting data in a new file acts strangely

  1. #1
    Registered User
    Join Date
    07-29-2015
    Location
    Germany
    MS-Off Ver
    Office 365
    Posts
    4

    Pasting data in a new file acts strangely

    Hello everyone,

    this is a bit hard to describe.
    I'm currently working on a module that does the following.
    A worksheet has an identifier column. All rows that contain a certain identifier (say 12345) are copied into an array. Then a new file is created and the contents of the array are pasted into the file.

    Filling the array works so far, I checked it by debugging and checking the contents of the array after filling. The array is arrData(x,y).
    Now, when I paste the contents of the array into the new file, I do it like this:

    Please Login or Register  to view this content.
    I start with A2 because the first row is the column descriptions.
    Also, I don't know why I actually have to transpose the array, but it is necessasary, otherwise rows and columns are switched on paste.

    The array contains 56 rows. However, instead of pasting these 56 rows, only the 11 last rows are in the new file. And they don't start at row 2, but at row 1.
    Currently I assume that it pastes a few rows, then jumps back to row 1, overwrites the rows it pasted, jumps back to the top and does it until only the last 11 rows are left.

    Does anyone know what's going on?

  2. #2
    Forum Guru :) Sixthsense :)'s Avatar
    Join Date
    01-01-2012
    Location
    India>Tamilnadu>Chennai
    MS-Off Ver
    2003 To 2010
    Posts
    12,788

    Re: Pasting data in a new file acts strangely

    Try this...

    Please Login or Register  to view this content.


    If your problem is solved, then please mark the thread as SOLVED>>Above your first post>>Thread Tools>>
    Mark your thread as Solved


    If the suggestion helps you, then Click *below to Add Reputation

  3. #3
    Forum Guru Kyle123's Avatar
    Join Date
    03-10-2010
    Location
    Leeds
    MS-Off Ver
    365 Win 11
    Posts
    7,239

    Re: Pasting data in a new file acts strangely

    Should be:
    Please Login or Register  to view this content.
    You don't need to transpose a 2 dimensional array, it's already in the format you need. I think you've also got your rows and columns mixed up (x & y), but without seeing the rest of the code I can't be sure

  4. #4
    Registered User
    Join Date
    07-29-2015
    Location
    Germany
    MS-Off Ver
    Office 365
    Posts
    4

    Re: Pasting data in a new file acts strangely

    Quote Originally Posted by :) Sixthsense :) View Post
    Try this...

    Please Login or Register  to view this content.
    I tried that before. It does pretty much the same. The only difference is that the rows now extend all the way to [XT], with the cells from [T] to [XT] being filled with #NV.

  5. #5
    Registered User
    Join Date
    07-29-2015
    Location
    Germany
    MS-Off Ver
    Office 365
    Posts
    4

    Re: Pasting data in a new file acts strangely

    Quote Originally Posted by Kyle123 View Post
    Should be:
    Please Login or Register  to view this content.
    You don't need to transpose a 2 dimensional array, it's already in the format you need. I think you've also got your rows and columns mixed up (x & y), but without seeing the rest of the code I can't be sure
    Huh... well without transposition, rows and columns are changed, I tried that.
    So... I basically fill it like

    Please Login or Register  to view this content.
    So basically the 2D array looks like the sheet.
    If needed, I can post the entire code. Just need to take the time to translate the names and comments.

  6. #6
    Forum Guru Kyle123's Avatar
    Join Date
    03-10-2010
    Location
    Leeds
    MS-Off Ver
    365 Win 11
    Posts
    7,239

    Re: Pasting data in a new file acts strangely

    I'm not sure from the above post if your problem is solved or not.

    If not, please upload a sample workbook and show us the rest of your code, there currently isn't enough to diagnose the problem:

    Make sure there is just enough data to demonstrate your need. Include a BEFORE sheet and an AFTER sheet in the workbook if needed to show the process you're trying to complete or automate. Make sure your desired results are shown, mock them up manually if necessary.

    Remember to desensitize the data.

    Click on GO ADVANCED and use the paperclip icon to open the upload window.

    View Pic

  7. #7
    Registered User
    Join Date
    07-29-2015
    Location
    Germany
    MS-Off Ver
    Office 365
    Posts
    4

    Re: Pasting data in a new file acts strangely

    Ok, here it is. The first sheet is the data ready to be processed. Random names and numbers have been inserted.
    The rightmost column (S) is the one that's important.
    Sheet 1 and sheet 2 are result samples. Imagine each of them to be a separate file. What data comes in which file depends on the rightmost column.

    The code is in module 1. It's probably terrible code, but I'm still very new to VBA, so my code isn't exactly elegant yet.
    Attached Files Attached Files

+ 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. problem with pasting data from notepad file
    By hunterage2000 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 11-13-2014, 06:00 AM
  2. Pasting data all of a sudden ruins pivot table and file
    By i03theda in forum Excel General
    Replies: 0
    Last Post: 10-23-2013, 05:06 AM
  3. Replies: 1
    Last Post: 04-02-2011, 06:39 AM
  4. Pasting data from a master file to two other files
    By Bob@Sun in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 11-17-2009, 02:50 PM
  5. Pasting/Compiling Data To The End Of A File
    By MWS in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 02-01-2006, 09:25 AM
  6. Searching for and Pasting Data to a new file
    By Elaine in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 01-10-2006, 03:20 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