+ Reply to Thread
Results 1 to 4 of 4

Repeat a execution of a VBA Code for each worksheets within the same workbook

Hybrid View

  1. #1
    Forum Contributor
    Join Date
    06-29-2012
    Location
    Calgary CA
    MS-Off Ver
    Excel 2010
    Posts
    117

    Question Repeat a execution of a VBA Code for each worksheets within the same workbook

    Hello Gurus:

    I have a code that works very well on its task but it only do the work for one worksheet.

    Would you write me a simple code that makes this code to repeat its work on each worksheet within the same workbook?


    Sub Test()
    For N = Cells(Rows.Count, 3).End(xlUp).Row To 2 Step -1
        If Cells(N, 1) = "" Then
            Cells(N - 1, 3) = Cells(N - 1, 3) & " " & Cells(N, 3)
            Rows(N).Delete
        End If
    Next N
    End Sub
    Thank you,

    Chris
    Last edited by aviatecar; 09-08-2014 at 12:55 PM. Reason: Forum Rule Compliance

  2. #2
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: Repeat a execution of a VBA Code for each worksheets within the same workbook

    Thank you for the code tags.

    Untested:

    Sub Test()
        Dim wks         As Worksheet
        Dim iRow        As Long
    
        For Each wks In Worksheets
            With wks
                For iRow = .Cells(.Rows.Count, "C").End(xlUp).Row To 2 Step -1
                    If .Cells(iRow, "A").Value = "" Then
                        .Cells(iRow - 1, "C").Value = .Cells(iRow - 1, "C").Value & " " & .Cells(iRow, "C").Value
                        .Rows(iRow).Delete
                    End If
                Next iRow
            End With
        Next wks
    End Sub
    Last edited by shg; 09-13-2014 at 04:29 PM.
    Entia non sunt multiplicanda sine necessitate

  3. #3
    Forum Contributor
    Join Date
    06-29-2012
    Location
    Calgary CA
    MS-Off Ver
    Excel 2010
    Posts
    117

    Re: Repeat a execution of a VBA Code for each worksheets within the same workbook

    Works like a charm!

    Thank you shg!

  4. #4
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: Repeat a execution of a VBA Code for each worksheets within the same workbook

    You're welcome.

+ 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. Need to repeat macro across multiple worksheets in workbook
    By iasiddiqui77 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 06-13-2014, 03:15 PM
  2. [SOLVED] Code execution ends when workbook opens
    By Alexander_Golinsky in forum Excel Programming / VBA / Macros
    Replies: 17
    Last Post: 12-03-2013, 02:23 PM
  3. VBA to Repeat over all worksheets in workbook
    By auscaf in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 11-03-2010, 09:02 PM
  4. [SOLVED] Disable VBA code execution when loading a workbook
    By Charles in forum Excel General
    Replies: 4
    Last Post: 10-14-2005, 05:05 PM
  5. where put code for automatic execution upon opening workbook?
    By Ian Elliott in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 06-17-2005, 02:05 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