+ Reply to Thread
Results 1 to 6 of 6

insert copied cells

  1. #1
    Registered User
    Join Date
    06-13-2008
    Posts
    12

    insert copied cells

    HI I have an annoying problem, its annoying because it work some times and sometimes doens't and I don't know why.

    What I am trying to do is filter a sheet, select the filtered data, copy it, insert it into another worksheet.
    I have a for loop that cycles through several worksheets inserting different filtered information from the main worksheet.
    This works just fine except sometimes instead of inserting the copied cells excel just inserts a single blank cell. So some of the worksheets have data inserted into then and some have just a single cell inserted.

    This is in Excel 2000

    here is the code snippet:

    Please Login or Register  to view this content.
    and this is the select case block that is called in the loop:

    Please Login or Register  to view this content.
    Why does the insert sometimes insert the copied cells and sometimes just insert a new blank cell? and how can I fix this?
    My suspicions are that its somthing to do with the way i'm selecting the filtered data to copy:

    Please Login or Register  to view this content.
    is there a better way of selecting this data?

    BTW: specifically the first two worksheets "North" and "Central" have just a blank cell inserted, and the other two sheets "South" and "HQ" have the copied data inserted properly. I have stepped through the code and the data is copied for the north and central sheets but it just doesn't get inserted.. Perhaps its not copying into the clipboard for some reason? Oh, and there is no difference between the north, central, south, and HQ worksheets. Thay are all copys of the main worksheet but with the name changed. Each of threse sheets has header data and footer sums which is why I need to insert the data between these rows.
    Last edited by mrcoffee; 06-13-2008 at 07:25 AM.

  2. #2
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200
    Not sure about your data layout without seeing it but I would think a PivotTable would be better than VBA to do this. See if this copies the filtered range better. An attached workbook would help us solve this.

    Please Login or Register  to view this content.
    Hope that helps.

    RoyUK
    --------
    For Excel Tips & Solutions, free examples and tutorials why not check out my web site

    Free DataBaseForm example

  3. #3
    Registered User
    Join Date
    06-13-2008
    Posts
    12
    I'm so stupid sometimes

    turns out that excel doesn't like inserting multiple ranges - once I added a few lines to sort the data by operational area before applying the filter it works like a charm.
    This is why some of the data was copying fine and some wasn't, some of the ranges were contigous data and some were multiple ranges.

    Thanks for your help anyway!

  4. #4
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200
    I would check out using a PivotTable.

  5. #5
    Registered User
    Join Date
    06-13-2008
    Posts
    12
    A pivot table isn't appropriate in this scenario, I would post up the workbook but its confidential payroll information.
    Suffice to say this is just a small part of the project, so far the macro is about 800 lines and draws data from 7 sources. Damn thing takes about 50 minutes to run, which is no fun when you're trying to test things.

    Cheers anyway.

  6. #6
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200
    You might be able to improve the time by removing any unnecessary selecting.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

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