+ Reply to Thread
Results 1 to 8 of 8

Looping through worksheets

  1. #1
    Forum Contributor
    Join Date
    02-24-2010
    Location
    BC, Canada
    MS-Off Ver
    Excel 2010
    Posts
    174

    Looping through worksheets

    Hi,

    I am trying to perform the same actions on all of the worksheets in my workbook. I have tried the following two codes but neither of them work:

    Please Login or Register  to view this content.
    Please Login or Register  to view this content.
    I tried that last one with "next" and "next ws".

    Neither of these are making all of the changes that are specified. Any thoughts?

    Thank you.
    Last edited by The Phil; 01-17-2014 at 03:23 PM.

  2. #2
    Valued Forum Contributor Sean Thomas's Avatar
    Join Date
    03-25-2012
    Location
    HerneBay, Kent, UK
    MS-Off Ver
    Excel 2007,2016
    Posts
    971

    Re: Looping through worksheets

    whats not working?
    is there an error? if so where is the error occuring?
    Regards
    Sean

    Please add to my reputation if you think i helped
    (click on the star below the post)
    Mark threads as "Solved" if you have your answer
    (Thread Tools->Mark thread as Solved)
    Use code tags when posting your VBA code:
    [code] Your code here [code]
    Please supply a workbook containing example Data:
    It makes its easier to answer your problem & saves time!

  3. #3
    Forum Expert judgeh59's Avatar
    Join Date
    02-07-2013
    Location
    Boise, Idaho
    MS-Off Ver
    Excel 2016
    Posts
    2,310

    Re: Looping through worksheets

    maybe try adding ws. to the beginning of cells and ranges...
    Ernest

    Please consider adding a * if I helped

    Nothing drives me crazy - I'm always close enough to walk....

  4. #4
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,644

    Re: Looping through worksheets

    Try this.
    Please Login or Register  to view this content.
    If posting code please use code tags, see here.

  5. #5
    Valued Forum Contributor Sean Thomas's Avatar
    Join Date
    03-25-2012
    Location
    HerneBay, Kent, UK
    MS-Off Ver
    Excel 2007,2016
    Posts
    971

    Re: Looping through worksheets

    what is Ryear? you dont have anything declared? is it a variable?
    if it cant find it, it will error or ignore the code

  6. #6
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: Looping through worksheets

    Is RYear specified in each sheet or do you need to reference a value from a specific sheet?

    Please Login or Register  to view this content.

  7. #7
    Forum Contributor
    Join Date
    02-24-2010
    Location
    BC, Canada
    MS-Off Ver
    Excel 2010
    Posts
    174

    Re: Looping through worksheets

    Thank you all for responding.

    I added the "ws.activate" line and that fixed it.

    My problem is that the cells weren't being updated on each sheet. Now it is working with that extra line of code.

    Thanks!!

  8. #8
    Registered User
    Join Date
    01-17-2014
    Location
    Egypt
    MS-Off Ver
    Excel 2010
    Posts
    25

    Re: Looping through worksheets

    It is now working
    i have added:
    Ws.Activate

    the final working code is
    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)

Similar Threads

  1. Looping through worksheets
    By terkel in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 11-25-2008, 03:54 AM
  2. Looping through worksheets
    By terkel in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 10-17-2008, 02:53 AM
  3. Looping through Worksheets
    By Steve in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 07-12-2005, 03:05 PM
  4. Looping across worksheets
    By Ramthebuffs in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 06-19-2005, 12:52 AM
  5. Looping through Worksheets
    By Kirk P. in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 02-07-2005, 02:06 PM

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