+ Reply to Thread
Results 1 to 2 of 2

code needed to create macro for button

Hybrid View

tryingtolearn code needed to create macro... 05-17-2012, 03:37 AM
venkat1926 Re: code needed to create... 05-17-2012, 08:24 AM
  1. #1
    Registered User
    Join Date
    05-15-2012
    Location
    Australia
    MS-Off Ver
    Excel 2010
    Posts
    10

    Smile code needed to create macro for button

    Can anyone please help. I have the following code that works well except I am missing one part of what I need. My problem is I need to create the macro to open the newly created sheet and assign it to the newly created button. (see code below) I also need the newly created button to be placed below the last button created on sheet1.

    Sub New_Contractor()
    '
    ' New_Contractor Macro
    'Creates a new sheet for a new contractor and names the sheet tab.
    '
        Sheet16.Visible = True
        Sheet16.Select
        Cells.Select
        Selection.Copy
        Sheets.Add After:=Sheets(Sheets.Count)
        ActiveSheet.Paste
        ActiveSheet.Name = InputBox("Please enter the name of the New Contractor")
        Range("F4").Select
        ActiveWindow.FreezePanes = True
        Range("b4").Select
        Sheet16.Visible = False
        Sheet1.Select
        Sheet1.Buttons.Add(191.25, 315, 95.25, 13.5).Select
        ***********code needed here to place button below the last button************
        Selection.Characters.Text = Sheets(Sheets.Count).Name
        Selection.OnAction =***********code needed here***********
        With Selection.Characters(Start:=1, Length:=14).Font
            .Name = "Calibri"
            .FontStyle = "Regular"
            .Size = 11
            .Strikethrough = False
            .Superscript = False
            .Subscript = False
            .OutlineFont = False
            .Shadow = False
            .Underline = xlUnderlineStyleNone
            .ColorIndex = 1
        End With
       Range("a1").Select
    End Sub
    Thanks to anybody who can help.

  2. #2
    Valued Forum Contributor
    Join Date
    06-17-2009
    Location
    Chennai,India
    MS-Off Ver
    Excel 2003,excel 2007
    Posts
    678

    Re: code needed to create macro for button

    I wonder whether I have understood. If the macro under button does the same thing why not have ONLY ONE button and make it to operate on the ACTIVE SHEET.
    I am not an expert. better solutions may be available
    $$$$venkat1926$$$$@gmail.com

+ 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