Results 1 to 3 of 3

Macro to loop in all sheets ...Please Help

Threaded View

gokzee Macro to loop in all sheets... 11-29-2012, 12:18 AM
gokzee Re: Macro to loop in all... 11-29-2012, 01:26 AM
arlu1201 Re: Macro to loop in all... 11-29-2012, 02:46 AM
  1. #1
    Forum Contributor
    Join Date
    11-08-2012
    Location
    Dubai
    MS-Off Ver
    Excel For Mac V16 365
    Posts
    145

    Macro to loop in all sheets ...Please Help

    Hiii Guys,,,

    i need to run a macro in all the sheets in the workbook except the first sheet.

    this is my macro

    Sub DelDupRows()
        Dim rngSrc As Range
        Dim NumRows As Integer
        Dim ThisRow As Integer
        Dim ThatRow As Integer
        Dim ThisCol As Integer
        Dim RightCol As Integer
        Dim J As Integer, K As Integer
         
        Application.ScreenUpdating = False
        Set rngSrc = ActiveSheet.Range(ActiveWindow.Selection.Address)
         
        NumRows = rngSrc.Rows.Count
        ThisRow = rngSrc.Row
        ThatRow = ThisRow + NumRows - 1
        ThisCol = rngSrc.Column
        RightCol = ThisCol + rngSrc.Columns.Count - 1
         
         'Start wiping out duplicates
        For J = ThisRow To (ThatRow - 1)
            If Cells(J, ThisCol) > "" Then
                For K = (J + 1) To ThatRow
                    If Cells(J, ThisCol) = Cells(K, ThisCol) Then
                        Cells(K, ThisCol) = ""
                    End If
                Next K
            End If
        Next J
         
         'Remove rows with empty key cells
        For J = ThatRow To ThisRow Step -1
            If Cells(J, ThisCol) = "" Then
                Range(Cells(J, ThisCol), Cells(J, RightCol)).EntireRow.Delete xlShiftUp
            End If
        Next J
        Application.ScreenUpdating = True
    End Sub
    i tried so much...with for,count etc.. but its running only on the active sheet

    kindly provide a solution


    thanks

    gokz
    Last edited by gokzee; 11-29-2012 at 02:55 AM.

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