Results 1 to 2 of 2

Loop through a subset of worksheets will not work

Threaded View

  1. #1
    Registered User
    Join Date
    01-27-2014
    Location
    Fresno, USA
    MS-Off Ver
    Excel 2007
    Posts
    47

    Loop through a subset of worksheets will not work

    Greetings,

    I'm trying to insert two rows in a subset of worksheets in a workbook by defining a range in a worksheet and loop through the worksheets in that range, but the code will only run on the active worksheet.
        Sub StatePIPData()
        Dim sheet_name As Range
        For Each sheet_name In Sheets("WS").Range("A:A")
            If sheet_name.Value = "" Then
                Exit For
            Else
                 'Insert 2 rows for 2011 and 2012's data
                 Range("A14").EntireRow.Insert
                 Cells(14, 1) = Cells(15, 1) + 1
                 Range("A14").EntireRow.Insert
                 Cells(14, 1) = Cells(15, 1) + 1
                 End If
            Next sheet_name
         End Sub
    Any thoughts on how I could get this loop to work?

    Thank you very much,
    Last edited by Leith Ross; 02-09-2014 at 06:14 PM. Reason: Added Code Tags

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] loop on Worksheets does not work
    By runneer in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 09-23-2013, 04:41 AM
  2. [SOLVED] Subset of worksheets
    By jlt199 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 07-29-2013, 03:45 PM
  3. [SOLVED] Loop max value/ match functions to work on multiple worksheets
    By KeithMale in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 06-04-2013, 07:13 PM
  4. Loop thru subset of properties?
    By geoB in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 11-04-2011, 12:05 AM
  5. Loop through worksheets within work book
    By kchm_2000 in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 01-11-2011, 06:09 AM

Tags for this Thread

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