Results 1 to 2 of 2

Trying to Give New Command Button Code from Another Sheet's Code

Threaded View

  1. #1
    Registered User
    Join Date
    08-10-2012
    Location
    Berlin,Penn
    MS-Off Ver
    Excel 2007
    Posts
    1

    Trying to Give New Command Button Code from Another Sheet's Code

    I have searched the internet for four days now and still cannot find a proper solution to my problem. I have a sheet called "Home." From this sheet I have a command button that creates a new sheet titled with the value in cell B3 which is "Oct". With the same command button, I have created a command button in the sheet "Oct." With the same command button on the "Home" sheet, I want to give the new command button in the "Oct" sheet code. Here is what I have:

    Private Sub CommandButton4_Click()
        Sheets("New").Cells.Select
        Selection.Copy
        Set NewSheet = Sheets.Add(Type:=xlWorksheet)
        NewSheet.Name = Range("B3").Value
        ActiveSheet.Paste
            With NewSheet
            ActiveSheet.OLEObjects.Add(ClassType:="Forms.CommandButton.1", Link:=True, DisplayAsIcon:=False, Left:=800, Top:=50, Width:=100, Height:=30).Select
            
            End With
    End Sub
    This code gives me the sheet "Oct" with a command button. I want this command button to automatically have code once it is made.

    Thanks to anyone that can help.
    Last edited by Cutter; 08-10-2012 at 09:42 AM. Reason: Added code tags

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