+ Reply to Thread
Results 1 to 4 of 4

adding userform command buttons

  1. #1
    borg
    Guest

    adding userform command buttons

    Hi,

    I want to for subroutine1 to add 5 commandbuttons to userform1 and when
    clicked, the commandbuttons will call another subroutine2. This is what I
    currently have to create the 5 commandbuttons. When clicked, the
    commandbuttons do nothing.

    sub subroutine1

    for i=1 to 5
    With UserForm1
    For i = 1 To 3
    Set Mycmd = .Controls.Add("Forms.CommandButton.1")
    Mycmd.Left = 0
    Mycmd.Top = 100 * i
    Mycmd.Width = 175
    Mycmd.Height = 20
    Next i
    UserForm1.Show
    End With

    end sub

    Thanks for you help!



  2. #2
    Yngve
    Guest

    Re: adding userform command buttons

    Hi borg

    goto
    http://www.contextures.com/xlUserForm01.html and here you will
    learn to Create a Userform

    Regads Yngve


  3. #3
    Paul Lautman
    Guest

    Re: adding userform command buttons

    Your code seems rather strange as it has two control variables with the same
    name

    Anyway, take a look at http://j-walk.com/ss/excel/tips/modGetOption.bas

    borg wrote:
    > Hi,
    >
    > I want to for subroutine1 to add 5 commandbuttons to userform1 and
    > when clicked, the commandbuttons will call another subroutine2. This
    > is what I currently have to create the 5 commandbuttons. When
    > clicked, the commandbuttons do nothing.
    >
    > sub subroutine1
    >
    > for i=1 to 5
    > With UserForm1
    > For i = 1 To 3
    > Set Mycmd = .Controls.Add("Forms.CommandButton.1")
    > Mycmd.Left = 0
    > Mycmd.Top = 100 * i
    > Mycmd.Width = 175
    > Mycmd.Height = 20
    > Next i
    > UserForm1.Show
    > End With
    >
    > end sub
    >
    > Thanks for you help!





  4. #4
    borg
    Guest

    Re: adding userform command buttons

    You are right about my strange code. But your suggestion really helped.
    Thank you!

    "Paul Lautman" wrote:

    > Your code seems rather strange as it has two control variables with the same
    > name
    >
    > Anyway, take a look at http://j-walk.com/ss/excel/tips/modGetOption.bas
    >
    > borg wrote:
    > > Hi,
    > >
    > > I want to for subroutine1 to add 5 commandbuttons to userform1 and
    > > when clicked, the commandbuttons will call another subroutine2. This
    > > is what I currently have to create the 5 commandbuttons. When
    > > clicked, the commandbuttons do nothing.
    > >
    > > sub subroutine1
    > >
    > > for i=1 to 5
    > > With UserForm1
    > > For i = 1 To 3
    > > Set Mycmd = .Controls.Add("Forms.CommandButton.1")
    > > Mycmd.Left = 0
    > > Mycmd.Top = 100 * i
    > > Mycmd.Width = 175
    > > Mycmd.Height = 20
    > > Next i
    > > UserForm1.Show
    > > End With
    > >
    > > end sub
    > >
    > > Thanks for you help!

    >
    >
    >
    >


+ 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