Results 1 to 2 of 2

How to run same code (VBA) for other sheet of a work book?

Threaded View

maftoun How to run same code (VBA)... 06-11-2012, 05:24 PM
wallyeye Re: Vba 06-11-2012, 07:11 PM
  1. #1
    Registered User
    Join Date
    06-08-2012
    Location
    USA
    MS-Off Ver
    2010
    Posts
    2

    How to run same code (VBA) for other sheet of a work book?

    Greetings,

    This is my VBA for 1st sheet of my workbook,
    It is in the Module 1
    Public Sub MyMacro()
        Sheets("a").Select
        Tempcell = 0
        For Each Bcell In Range("j14:j26")
            If (Bcell = 0) Then
                Range("j28") = Tempcell
            End If
            If Not (Bcell = 0) Then
                Tempcell = Bcell
            End If
        Next Bcell
        Sheets("a").Select
        Tempcell = 0
        For Each Bcell In Range("u14:u25")
            If (Bcell = 0) Then
                Range("u28") = Tempcell
            End If
            If Not (Bcell = 0) Then
                Tempcell = Bcell
            End If
        Next Bcell
    
        
    End Sub

    Also I have
    Private Sub Worksheet_SelectionChange(ByVal Target As Range)
    Run "MyMacro"
    End Sub
    In worksheet (a) Selection change of Excel Object.

    My question is how I can to "RUN" same VBA for other 7 sheets (b - h) of same workbook ?

    Thanks for your help
    Last edited by maftoun; 06-12-2012 at 03:38 PM. Reason: Use code tags in future.

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