+ Reply to Thread
Results 1 to 4 of 4

Runing two macros triggered by a button

  1. #1
    JackR
    Guest

    Runing two macros triggered by a button

    I have the first macro set-up to start when a button is clicked, I would like
    bothe the macros to run when then button is clicked, any help would be great,
    not real up on this macro stuff yet.

    MACRO 1 (triggered by button)
    Sub nametab()
    Dim i As Integer
    On Error Resume Next
    For i = 1 To Sheets.Count
    Sheets(i).Name = Sheets(i).Range("G1").Value
    Next i
    On Error GoTo 0
    End Sub

    WANT TO ADD THE FOLLOWING TO TRIGGER AT THE SAME TIME
    Sub CellInfooter()
    With ActiveSheet
    .PageSetup.CenterFooter = .Range("G1").Text
    End With
    End Sub



    Thanks

  2. #2
    Paul B
    Guest

    Re: Runing two macros triggered by a button

    Jack, why not just put them together in one,

    Sub nametab()
    Dim i As Integer
    On Error Resume Next
    For i = 1 To Sheets.Count
    Sheets(i).Name = Sheets(i).Range("G1").Value
    Next i
    With ActiveSheet
    .PageSetup.CenterFooter = .Range("G1").Text
    End With
    On Error GoTo 0
    End Sub


    or like this

    Sub nametab()
    Dim i As Integer
    On Error Resume Next
    For i = 1 To Sheets.Count
    Sheets(i).Name = Sheets(i).Range("G1").Value
    Next i
    With ActiveSheet
    .PageSetup.CenterFooter = .Range("G1").Text
    End With
    CellInfooter
    On Error GoTo 0
    End Sub

    Sub CellInfooter()
    With ActiveSheet
    .PageSetup.CenterFooter = .Range("G1").Text
    End With
    End Sub


    --
    Paul B
    Always backup your data before trying something new
    Please post any response to the newsgroups so others can benefit from it
    Feedback on answers is always appreciated!
    Using Excel 2002 & 2003

    "JackR" <[email protected]> wrote in message
    news:[email protected]...
    > I have the first macro set-up to start when a button is clicked, I would

    like
    > bothe the macros to run when then button is clicked, any help would be

    great,
    > not real up on this macro stuff yet.
    >
    > MACRO 1 (triggered by button)
    > Sub nametab()
    > Dim i As Integer
    > On Error Resume Next
    > For i = 1 To Sheets.Count
    > Sheets(i).Name = Sheets(i).Range("G1").Value
    > Next i
    > On Error GoTo 0
    > End Sub
    >
    > WANT TO ADD THE FOLLOWING TO TRIGGER AT THE SAME TIME
    > Sub CellInfooter()
    > With ActiveSheet
    > .PageSetup.CenterFooter = .Range("G1").Text
    > End With
    > End Sub
    >
    >
    >
    > Thanks




  3. #3
    Dave Peterson
    Guest

    Re: Runing two macros triggered by a button

    If you only use cellinfooter when you click that button:

    MACRO 1 (triggered by button)
    Sub nametab()
    Dim i As Integer
    On Error Resume Next
    For i = 1 To Sheets.Count
    Sheets(i).Name = Sheets(i).Range("G1").Value
    Next i
    On Error GoTo 0

    With ActiveSheet
    .PageSetup.CenterFooter = .Range("G1").Text
    End With
    End Sub

    If you want to be able to use cellinfooter independently of the button:

    MACRO 1 (triggered by button)
    Sub nametab()
    Dim i As Integer
    On Error Resume Next
    For i = 1 To Sheets.Count
    Sheets(i).Name = Sheets(i).Range("G1").Value
    Next i
    On Error GoTo 0
    call cellinfooter
    End Sub

    WANT TO ADD THE FOLLOWING TO TRIGGER AT THE SAME TIME
    Sub CellInfooter()
    With ActiveSheet
    .PageSetup.CenterFooter = .Range("G1").Text
    End With
    End Sub

    JackR wrote:
    >
    > I have the first macro set-up to start when a button is clicked, I would like
    > bothe the macros to run when then button is clicked, any help would be great,
    > not real up on this macro stuff yet.
    >
    > MACRO 1 (triggered by button)
    > Sub nametab()
    > Dim i As Integer
    > On Error Resume Next
    > For i = 1 To Sheets.Count
    > Sheets(i).Name = Sheets(i).Range("G1").Value
    > Next i
    > On Error GoTo 0
    > End Sub
    >
    > WANT TO ADD THE FOLLOWING TO TRIGGER AT THE SAME TIME
    > Sub CellInfooter()
    > With ActiveSheet
    > .PageSetup.CenterFooter = .Range("G1").Text
    > End With
    > End Sub
    >
    > Thanks


    --

    Dave Peterson

  4. #4
    JackR
    Guest

    Re: Runing two macros triggered by a button

    Thank you, that worked, I knew it would be simple

    "Paul B" wrote:

    > Jack, why not just put them together in one,
    >
    > Sub nametab()
    > Dim i As Integer
    > On Error Resume Next
    > For i = 1 To Sheets.Count
    > Sheets(i).Name = Sheets(i).Range("G1").Value
    > Next i
    > With ActiveSheet
    > .PageSetup.CenterFooter = .Range("G1").Text
    > End With
    > On Error GoTo 0
    > End Sub
    >
    >
    > or like this
    >
    > Sub nametab()
    > Dim i As Integer
    > On Error Resume Next
    > For i = 1 To Sheets.Count
    > Sheets(i).Name = Sheets(i).Range("G1").Value
    > Next i
    > With ActiveSheet
    > .PageSetup.CenterFooter = .Range("G1").Text
    > End With
    > CellInfooter
    > On Error GoTo 0
    > End Sub
    >
    > Sub CellInfooter()
    > With ActiveSheet
    > .PageSetup.CenterFooter = .Range("G1").Text
    > End With
    > End Sub
    >
    >
    > --
    > Paul B
    > Always backup your data before trying something new
    > Please post any response to the newsgroups so others can benefit from it
    > Feedback on answers is always appreciated!
    > Using Excel 2002 & 2003
    >
    > "JackR" <[email protected]> wrote in message
    > news:[email protected]...
    > > I have the first macro set-up to start when a button is clicked, I would

    > like
    > > bothe the macros to run when then button is clicked, any help would be

    > great,
    > > not real up on this macro stuff yet.
    > >
    > > MACRO 1 (triggered by button)
    > > Sub nametab()
    > > Dim i As Integer
    > > On Error Resume Next
    > > For i = 1 To Sheets.Count
    > > Sheets(i).Name = Sheets(i).Range("G1").Value
    > > Next i
    > > On Error GoTo 0
    > > End Sub
    > >
    > > WANT TO ADD THE FOLLOWING TO TRIGGER AT THE SAME TIME
    > > Sub CellInfooter()
    > > With ActiveSheet
    > > .PageSetup.CenterFooter = .Range("G1").Text
    > > End With
    > > End Sub
    > >
    > >
    > >
    > > Thanks

    >
    >
    >


+ Reply to Thread

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