+ Reply to Thread
Results 1 to 2 of 2

For Each worksheet help

  1. #1
    Registered User
    Join Date
    09-30-2010
    Location
    Canada
    MS-Off Ver
    Excel 2013
    Posts
    33

    For Each worksheet help

    Hi All,

    I am working a spreadsheet with 12 sheets in the workbook and I need to clean up each worksheet. However when I try to use a for each code it isn't quite working as intended.

    Please Login or Register  to view this content.
    It doesn't loop through each worksheet and in the end it repeats absPrices 12 times so that I now have 11 extra "ABS Prices" columns and I am not too sure where the error is, thanks!

  2. #2
    Forum Expert
    Join Date
    07-31-2010
    Location
    California
    MS-Off Ver
    Excel 2007
    Posts
    4,070

    Re: For Each worksheet help

    Within each subroutine you are not specifying "ws" as part of the range and as such it is referencing only the active sheet. In addition, you are deleting rows incorrectly. Furthermore, you would need to publicly declare the variable ws for it to work across subroutines. Lastly, it would probably be best for you to just incorporate this all as one subroutine rather than multiple routines (unless you trigger them manually for different reasons)

    Please Login or Register  to view this content.
    Last edited by stnkynts; 02-26-2015 at 08:21 PM. Reason: Edit: For the ws in front of Rows(i)

+ 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. Macro to select worksheet based on cell value and then return data to diff worksheet
    By clnossok in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 04-22-2013, 07:48 PM
  2. [SOLVED] Copy data from a worksheet and paste to worksheet with a similar worksheet name
    By maacmaac in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 10-21-2012, 04:02 AM
  3. Copy data from a worksheet and paste to worksheet with a similar worksheet name
    By maacmaac in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 10-21-2012, 02:49 AM
  4. Replies: 3
    Last Post: 10-16-2012, 09:02 AM
  5. Replies: 3
    Last Post: 03-12-2006, 06:00 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