Results 1 to 7 of 7

Help with a loop through all sheets

Threaded View

  1. #1
    Registered User
    Join Date
    08-07-2013
    Location
    Saudi Arabia
    MS-Off Ver
    Excel 2007 - 2010
    Posts
    73

    Help with a loop through all sheets

    MorningReport.xls

    Hello guys,

    I have this macro, which I need to run in through all sheets but I haven't find the way. Could you help me? thanks!!


    Sub DeleteSheets()
    'Deletes the sheets when it doesnt find the dims.
    
    Dim CP(3), found_col, found_cl, count
    CP(0) = "WSD"
    CP(1) = "AFM"
    CP(2) = "DKD"
    CP(3) = "SDF"
    count = 0
    search_routine:
    On Error GoTo not_found
    Set found_col = Workbooks("MorningReport.xls").ActiveSheet.Cells.Find( _
        What:="Resp. Co", After:=Workbooks("MorningReport.xls").ActiveSheet.Range("A1"), _
        LookIn:=xlFormulas, LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
        MatchCase:=False, SearchFormat:=False).EntireColumn
    Set found_cl = found_col.Find(CP(count))
    If found_cl Is Nothing Then GoTo not_found
    
    Exit Sub
    not_found:
    If count = 3 Then
        Application.DisplayAlerts = False
        ActiveSheet.Delete
        Application.DisplayAlerts = True
    Else
        count = count + 1
        GoTo search_routine
    End If
    End Sub
    Last edited by jnh0; 08-13-2013 at 04:12 AM.

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] Loop not going through different sheets
    By KeithMale in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 05-30-2013, 06:57 PM
  2. [SOLVED] loop action through all sheets in workbook skipping certain sheets
    By sawa85sa in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 04-10-2013, 06:40 PM
  3. Loop through sheets
    By AnthonyWB in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 07-28-2011, 10:02 AM
  4. Loop for available sheets
    By rinch in forum Excel Programming / VBA / Macros
    Replies: 14
    Last Post: 05-20-2011, 09:40 AM
  5. Loop through 2 sheets
    By Treuz in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 10-14-2009, 03:50 PM

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