+ Reply to Thread
Results 1 to 3 of 3

loop macro for each sheet

  1. #1
    Forum Contributor
    Join Date
    04-03-2009
    Location
    USA, California
    MS-Off Ver
    Excel 2007
    Posts
    385

    loop macro for each sheet

    Below is the code I want to loop, I have a loop in there but it doesn't advance the code to the next worksheet. all I need help with is making the below code do its thing for each sheet in a workbook. Basically what this sheet does is copy information from 1 sheet then pastes it in a new sheet on 18 Ted Reponses (dstWB), but the problem is that when it goes back to the original Workbook (orgWB) it does not advance forward one worksheet. The code that is commented out is not active due to slowing the code down while testing but will be re enabled once everything else is active. If sample files are needed I can attach them.

    Please Login or Register  to view this content.

  2. #2
    Valued Forum Contributor rwgrietveld's Avatar
    Join Date
    09-02-2008
    Location
    Netherlands
    MS-Off Ver
    XL 2007 / XL 2010
    Posts
    1,671

    Re: loop macro for each sheet

    You have many things inside the For each loop that should be outside the loop
    Please Login or Register  to view this content.
    With this code:
    Please Login or Register  to view this content.
    you copy all cells and that is a bit much.

    Summarizing: The code looks like a recorded macro, adjusted to make it work. This is a bit strange to me as you have been around for a while on this forum?

    If you would like us to make this into a proper VBA script please specify what you need:
    1) From each source sheet copy content to new WB in a new Sheet (name should be date?)

    Why do you need to hide/unhide (remove) subtotal

    Maybe it is best to split your code in compact modules that do just 1 thing instead of many things.
    Last edited by rwgrietveld; 11-05-2009 at 05:04 AM.
    Looking for great solutions but hate waiting?
    Seach this Forum through Google

    www.Google.com
    (e.g. +multiple +IF site:excelforum.com/excel-general/ )

    www.Google.com
    (e.g. +fill +combobox site:excelforum.com/excel-programming/ )

    Ave,
    Ricardo

  3. #3
    Forum Contributor
    Join Date
    04-03-2009
    Location
    USA, California
    MS-Off Ver
    Excel 2007
    Posts
    385

    Re: loop macro for each sheet

    Yeah not overly worried about how efficient the code is or isn't because the loop portion needs to only work to copy the contents of one workbook to another workbook, eliminate the extra data so as to have a smaller file when viewing the information. The big file contains all data were the other one contains more specific data thereby reducing the file size when that set of data is used.

    I found something that works
    Please Login or Register  to view this content.
    And yes I have been around for awhile, slowly learning things and trying to figure out how to do things before asking for help with online research. Some of the code in this post was hand written and some was recorded, I don't remember the wording on a great deal of the code but I do know what I need to do, sometimes what I come up with isn't "pretty" but it works until I learn a more efficient method.

+ 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