+ Reply to Thread
Results 1 to 4 of 4

Macro across all worksheets

  1. #1
    Registered User
    Join Date
    09-04-2006
    Posts
    2

    Macro across all worksheets

    Hi.

    I've written a macro in excel that applies some formatting across a spreadsheet. What I now need to do is to apply that formatting across all the spreadsheets in a workbook when there are different numbers of spreadsheets in each workbook.

    I've different approaches to this so far using for...next and for each...next but all these do is loop the same format onto the first spreadsheet and leave the others untouched.

    Does anyone know how to make it move from spreadsheet to another when the number of sheets in the book is unknown?

    Thanks.

  2. #2
    Forum Expert Carim's Avatar
    Join Date
    04-07-2006
    Posts
    4,070
    Hi Ryn,

    Dim WS As Worksheet

    For Each WS In ThisWorkbook.Worksheets
    insert your code
    Next

    HTH

    Cheers
    Carim

  3. #3
    Registered User
    Join Date
    09-04-2006
    Posts
    2
    Thats what I have tried so far and it doesn't want to work.
    I've included the code that I've got so far but when I run it, it only runs on the sheet I currently have active and ignores the inactive ones.

    Please Login or Register  to view this content.

  4. #4
    Forum Contributor
    Join Date
    03-15-2005
    Location
    North Carolina
    MS-Off Ver
    2003 & 2007
    Posts
    180
    Place WS.Select in the line below the For loop. If you dont want to see all the screens bouncing around. Type Application.ScreenUpdating = False in the line above the for loop.

+ 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