+ Reply to Thread
Results 1 to 6 of 6

Loop code for certain worksheets in workbook

  1. #1
    Forum Contributor
    Join Date
    06-13-2009
    Location
    Australia
    MS-Off Ver
    Excel 2016
    Posts
    245

    Smile Loop code for certain worksheets in workbook

    Hello, could some one please be so kind as to help me loop my VBA code (Excel 2003) so that it performs the same procedure for worksheets: E-1, E-2, E-3, E-4. I am sorry about the large file sizes of the attached workbooks. I made them as small as possible. The original spreadsheet (which is not mine) is 35Mb. I was asked to create this macro on a poorly designed spreadsheet

    The code shown below does work OK (unfortunately, I am not a VBA programmer) so I guess the code is poorly written.

    If any one is able to please help, then they will need to have both workbooks open at the same time.

    At the moment when you run the code, it will only do worksheet named: E-1.

    In order to keep the file size down, I removed 15 other worksheets. I need the loop to only loop through specific worksheets: E-1, E-2, E-3 & E-7. There are other worksheets in the original spreadsheet that have worksheets named: E-16 & E-20 for example that I do not wish to include in the loop.

    Once the data is copied and pasted into Workbook named: HR Locations and into worksheet named: 1 Mth and Range: A3 then any other data from worksheets E-2, E-3 & E-7 needs to be appended at the bottom of any data that was copied from worksheet E-1 in worksheet named: 1 Mth.

    If you require further clarification, please let me know.

    Kind regards,

    Chris

    Please Login or Register  to view this content.
    Attached Files Attached Files
    Last edited by longbow007; 06-18-2010 at 01:06 AM.

  2. #2
    Forum Contributor
    Join Date
    06-13-2009
    Location
    Australia
    MS-Off Ver
    Excel 2016
    Posts
    245

    Re: Loop code for certain worksheets in workbook

    I just googled the Internet and found some hopefully useful VBA code to find the last cell in Workbook named: HR Locations Worksheet named: 1 Mth. I hope this will help with the appending of data

    Please Login or Register  to view this content.

  3. #3
    Forum Expert pike's Avatar
    Join Date
    12-11-2005
    Location
    Alstonville, Australia
    MS-Off Ver
    2016
    Posts
    5,330

    Re: Loop code for certain worksheets in workbook

    Hi longbow007,
    Something along the lines of this "find" synatx ... would be a starting point
    Please Login or Register  to view this content.
    which can develop into more complex as

    Please Login or Register  to view this content.
    with some offset and resizing.. ect will do the trick ..
    If the solution helped please donate to RSPCA

    Site worth visiting: Rabbitohs

  4. #4
    Forum Contributor
    Join Date
    06-13-2009
    Location
    Australia
    MS-Off Ver
    Excel 2016
    Posts
    245

    Re: Loop code for certain worksheets in workbook

    Hi pike, thanks so much for this VBA code. I am unsure how it fits in with my code as shown above in my original post. I really do not know or understand how to use this code in the form that you have so kindly given it to me.

    Is there any change please that you could be so kind as to implement your code with mine as I have no idea how to do this.

    Your hard work and efforts are very much appreciated.

    Kind regards,

    Chris

  5. #5
    Forum Contributor
    Join Date
    06-13-2009
    Location
    Australia
    MS-Off Ver
    Excel 2016
    Posts
    245

    Smile Re: Loop code for certain worksheets in workbook

    Hello, I am trying to fix my macro is small "chunk" size pieces so that it may be easier to obtain an overall solution. The following code (once it is fixed) will help me create a loop (which I do not really know how to do) so that I can selectively choose worksheets to loop through. Could some one please help modify my code to do the following:

    I am trying to create a loop that will only loop through workbook named: Book1.xls (copy attached with dummy data) worksheets named: E-1, E-2 and E-7 only in my Excel 2003 workbook (attached with dummy data).

    The AutoFilters for each of these worksheets: E-1, E-2, E-3, E-7, E-9, E-11 are switch on and have filters applied.

    Upon each iteration of looping through the macro, the following line of code is executed. This code works fine for the first iteration loop, however I need the following iterations to paste the filtered data to the worksheet named: 1 Mth in the last cell (so that the data is appended).

    I simply do not know how to make this happen.

    So if some one could please help me modify my macro and make it so that the data is appended in worksheet named 1 Mth, then it would be greatly appreciated.

    Kind regards,

    Chris



    Please Login or Register  to view this content.


    Please Login or Register  to view this content.
    Attached Files Attached Files

  6. #6
    Forum Contributor
    Join Date
    06-13-2009
    Location
    Australia
    MS-Off Ver
    Excel 2016
    Posts
    245

    Re: Loop code for certain worksheets in workbook

    Hello again, I thought I would share my current solution of being able to loop through selective worksheets within a workbook and append the data to a destination worksheet.



    My special thanks to Ron de Bruin - even though I "butchered" his excellent code

    Many thanks to all those wonderful people who have kindly helped me

    Cheers,

    Chris




    Please Login or Register  to view this content.

+ 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