+ Reply to Thread
Results 1 to 3 of 3

If the worksheet name begins with "CAL", copy the table to a new worksheet

  1. #1
    Forum Contributor
    Join Date
    03-24-2009
    Location
    London, UK
    MS-Off Ver
    Excel 2007
    Posts
    178

    If the worksheet name begins with "CAL", copy the table to a new worksheet

    Hi all,

    I wonder if you could help me please?

    I have a worksheet called "Summary".
    I have lots of other sheets too and sheets which have a name beginning with the letters "CAL" have got data tables in them.
    Ideally I would have a macro that loops through all sheets which begin with "CAL" and copies the data table into the "Summary" sheet, one underneath the other.

    My problem is with the looping. Below is the code I currently have.

    Thank you!

    Please Login or Register  to view this content.
    Last edited by Jessica.Bush; 06-20-2011 at 12:56 PM.

  2. #2
    Forum Expert Colin Legg's Avatar
    Join Date
    03-30-2008
    Location
    UK
    MS-Off Ver
    365
    Posts
    1,256

    Re: If the worksheet name begins with "CAL", copy the table to a new worksheet

    Hi Jessica,

    Your code is very close, but you're missing With... End With statements. For example, here:
    Please Login or Register  to view this content.
    You need to make sure that it knows that it should be looking at cells on xSheet.

    If your code runs (no compile error) then I guess you've got a With... End With block outside of the loop you've posted, which means that the properties beginning with dots (.) inside your loop are looking at the wrong sheet?

    Also, when you copy and paste over, you better make sure that you're not overwriting the last row of data on the summary sheet.
    Hope that helps,

    Colin

    RAD Excel Blog

  3. #3
    Forum Contributor
    Join Date
    03-24-2009
    Location
    London, UK
    MS-Off Ver
    Excel 2007
    Posts
    178

    Re: If the worksheet name begins with "CAL", copy the table to a new worksheet

    D'oh, how silly!

    Thank you so much, I have fixed it now (and am stamping my feet with excitement which made my colleague think it was thundering!). :-)

    Also, thanks for pointing out the copying over the last row of data - will need to change that!

    Jessica

+ 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