+ Reply to Thread
Results 1 to 8 of 8

Excel 2010 - Problems with auto copy from sheet to sheet

  1. #1
    Registered User
    Join Date
    02-05-2014
    Location
    UK
    MS-Off Ver
    Excel 2010
    Posts
    16

    Excel 2010 - Problems with auto copy from sheet to sheet

    Good Evening.

    Hello and thank you for allowing me to join your forum.

    I am a basic user attempting a personal project that if works, will save me time daily repeat typing. I will copy and past a description of my problem that I have written on a separate sheet in the attached workbook.

    I click the drop down menu in cell G2 and select TWO from the Report - Room sheet. A formula looks down Colum A in master info sheet, finds all entries that are listed for room TWO. Takes the rows that if matched and copies the data from the Master Info sheet, Colum's B,C and D and copies it to columns A,B and C in the Report - Room sheet.

    If I changed the room number to Three, the formula will then look for all rows that are listed in Three.

    If possible, if anyone can help me, I'd like to learn how you managed to do it so I can try myself on a duplicate workbook


    Please contact me with any questions, as I will help all I can.

    Regards
    Gary
    Attached Files Attached Files

  2. #2
    Forum Expert daffodil11's Avatar
    Join Date
    07-11-2013
    Location
    Phoenixville, PA
    MS-Off Ver
    MS Office 2016
    Posts
    4,465

    Re: Excel 2010 - Problems with auto copy from sheet to sheet

    This is probably the most awesome thing I'll write this month.

    Here you go!

    I'll follow up with another post describing what I did, to the best of my ability.

    Copy of Combined%20Project%201(1).xlsm
    Last edited by daffodil11; 02-05-2014 at 09:15 PM.
    Make Mom proud: Add to my reputation if I helped out!

    Make the Moderators happy: Mark the Thread as Solved if your question was answered!

  3. #3
    Forum Expert daffodil11's Avatar
    Join Date
    07-11-2013
    Location
    Phoenixville, PA
    MS-Off Ver
    MS Office 2016
    Posts
    4,465

    Re: Excel 2010 - Problems with auto copy from sheet to sheet

    Here's the Visual Basic code I put together that does everything:

    Please Login or Register  to view this content.
    And a second piece of code..

    Please Login or Register  to view this content.

    First I designed a standard Advanced Filter Macro.

    Advanced Filtering works by comparing a table of data (that has headers) to a set of criteria, which is just a list of those same headers with something below it in the next row. In your case, we want to compare the table to Room Number and Two.

    First, I added an extra tab with your table headers at the top. In the row right beneath Room Number I put ='Report - Room'!G2 so that it autopopulates with the value you want to filter against. A1:I2 represents the filter.

    Next, I used the following code to look at your raw data, compare it to the Filter criteria I've designed, and then instantly paste it to A4 right below the filter.
    This is the heart of every basic advanced filter macro.
    Please Login or Register  to view this content.
    The reason for this, is that its hard to paste the data as it is into merged cells, so this is sort of a baby step in between.

    The second half of the code finds where the last row of data is. Now it knows Row 5 to ??? is what it cares about. Now it copies the first cell from column B into A5:A8, which has to be specifically spelled out because of the merged cell. It adds 4 to the row numbers, and pastes the next value into A9:A12 and so on.

    It then repeats the same process for each row it found down Column C and then down Column D.


    In the beginning of this subroutine, I put Application.Updating = False which tells Excel to stop updating while this is running, otherwise you'd see Excel jump around as it looks at different tabs and pastes into each cell. This is followed by a clear command, which clears your form and filter tab so that you have fresh results every time. At the very end of the whole thing, we tell Excel to turn the ScreenUpdating back on.



    The second code block I wrote it a Worksheet Change Event. This type of code goes directly onto a worksheet's VB page. It states that if something I declare changes, to run. In my code, I said if G2 (the dropdown on Report - Rooms) changes, run the Filtering and Pasting macro.

    So, now every time you change the dropdown it will run through all of that code all over again.
    Last edited by daffodil11; 02-05-2014 at 09:35 PM.

  4. #4
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,946

    Re: Excel 2010 - Problems with auto copy from sheet to sheet

    Hi and welcome to the forum

    Here is another option if you dont want to/cant use VBA. It uses a helper column on Master sheet (I used J, you can use whatever you want, just change the references inthe nexy formula), with this , copied down...
    =IF(A2='Report - Room'!$G$2,COUNTIF('Master INFO'!$A$2:A2,'Master INFO'!A2),"")

    Then, make sure the headings on each sheet are the same (change Project No: to Project No, or vise versa)
    =IFERROR(INDEX('Master INFO'!$A:$I,MATCH((ROW()-1)/4,'Master INFO'!$J:$J,0),MATCH('Report - Room'!A$3,'Master INFO'!$A$1:$I$1,0)),"")

    Edit: Sorry daffodil, that looks like an awesome job you did there, my VBA sucks, so I have become a formula jockey lol
    Last edited by FDibbins; 02-05-2014 at 09:46 PM.
    1. Use code tags for VBA. [code] Your Code [/code] (or use the # button)
    2. If your question is resolved, mark it SOLVED using the thread tools
    3. Click on the star if you think someone helped you

    Regards
    Ford

  5. #5
    Forum Expert daffodil11's Avatar
    Join Date
    07-11-2013
    Location
    Phoenixville, PA
    MS-Off Ver
    MS Office 2016
    Posts
    4,465

    Re: Excel 2010 - Problems with auto copy from sheet to sheet

    Thanks for the edit, I feel better now.

    I'm rather bad at it myself but I felt like tackling a challenge by trying to circumvent VBs limitation on pasting into merged cells.

    It was 90% franken-coding and 10% ingenuity. I'll get around to really learning it eventually.

  6. #6
    Registered User
    Join Date
    02-05-2014
    Location
    UK
    MS-Off Ver
    Excel 2010
    Posts
    16

    Re: Excel 2010 - Problems with auto copy from sheet to sheet

    Many thanks daffodil11 and FDibbins

    daffodil11 - Thanks for your Macro's. Do you know if Macro's work on a SharePoint site? Doesn't overly an issues as I will just leave the file on the laptop and work from that. One thing I did notice was on the Report Room sheet, Column C (surname) would copy what it was auto generating in Column B (Project No)

    As I have said prior, the names of the forms, and headings are not the correct words. Would your Macro change itself when I change the names?


    FDibbins - Again, many thanks! Although I became stuck as I was unsure where to put the formulas. Really sorry.

    Regards
    Gary

  7. #7
    Forum Expert daffodil11's Avatar
    Join Date
    07-11-2013
    Location
    Phoenixville, PA
    MS-Off Ver
    MS Office 2016
    Posts
    4,465

    Re: Excel 2010 - Problems with auto copy from sheet to sheet

    Assmuming the layout and tabs remain the same, nothing needs to be changed. All you would need to do is to copy the headers from your actual into A1 of the Filter tab, and then change the value directly below that first header to target the dropdown's cell.

    If tab names changes, this can be easily modified in the code.

  8. #8
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,946

    Re: Excel 2010 - Problems with auto copy from sheet to sheet

    Copy this into J2, and then copy down as far as you need it to go...
    =IF(A2='Report - Room'!$G$2,COUNTIF('Master INFO'!$A$2:A2,'Master INFO'!A2),"")

    For this to work, you need to make sure the headings on each sheet are the same. For instance, on sheet 1 you have "Project No:" but on sheet 2, you only have "Project No"...make them the same

    Then, where you want the answers to be, copy this, and then put this in A5, and copy down and across
    =IFERROR(INDEX('Master INFO'!$A:$I,MATCH((ROW()-1)/4,'Master INFO'!$J:$J,0),MATCH('Report - Room'!A$3,'Master INFO'!$A$1:$I$1,0)),"")[/QUOTE]

+ 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. Trying to copy data from multiple sheets to a new sheet in 1 workbook (EXCEL 2010)
    By maurerma in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 01-17-2014, 12:28 PM
  2. Workbook Sheet Copy not working with Excel 2010
    By Big Jim in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 02-26-2013, 07:43 AM
  3. [SOLVED] macro to auto copy data from multiple sheet to one master sheet
    By roger556 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 10-30-2012, 01:52 AM
  4. [SOLVED] Copy and mid cells from one sheet to another in Excel 2010 using macro(VBA)
    By craigartemis in forum Excel Programming / VBA / Macros
    Replies: 13
    Last Post: 07-16-2012, 07:28 AM
  5. Cannot copy sheet from Excel 2007 to Excel 2010 - Destination Contains Fewer Rows
    By m3atball in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 06-02-2011, 01:33 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