+ Reply to Thread
Results 1 to 6 of 6

Code to Make a Lot of Command Buttons On a Userform and name them

  1. #1
    Registered User
    Join Date
    10-15-2013
    Location
    Sydney,Australia
    MS-Off Ver
    Excel 2010
    Posts
    5

    Code to Make a Lot of Command Buttons On a Userform and name them

    I'm trying to use command buttons as pixels on a user form.

    I need to create a user form containing 51x51 (a square 51 command buttons in length, 51 in height) filled with command buttons 7 in length and 7 in height.

    Also it needs to name them based on their position as if they're arranged in an on an x-y graph where the 26th command button in the 26th row is Cmd00 and then they go out from that to Cmd2525 in the top right cnr and Cmd-25-25 in the bottom right corner.

    I have no idea how to do this programatically and I'm not particularly keen on doing it manually.

    Thanks for your help in advanced

  2. #2
    Forum Contributor
    Join Date
    01-17-2013
    Location
    Belgium
    MS-Off Ver
    Excel 2010
    Posts
    211

    Re: Code to Make a Lot of Command Buttons On a Userform and name them

    Create a new userForm
    double click on it
    copy below code to it
    go back to the userfomr and play it

    let me know if this is what you want to go to (it looks small to me)

    Please Login or Register  to view this content.
    If solved remember to mark Thread as solved , to mark your thread as Solved select Thread Tools and click Mark thread as Solved.

    I can't read the mind of my wife so then I get picture but no sound .... and then I mostly get the idea, same goes here picture your outcome and I get the idea.

  3. #3
    Registered User
    Join Date
    10-15-2013
    Location
    Sydney,Australia
    MS-Off Ver
    Excel 2010
    Posts
    5

    Re: Code to Make a Lot of Command Buttons On a Userform and name them

    That's perfect! Only Problem is that I want to make it so it's on the userform design. Like it needs to be there when I'm designing the userform. How can I use that code in a macro?

  4. #4
    Forum Contributor
    Join Date
    01-17-2013
    Location
    Belgium
    MS-Off Ver
    Excel 2010
    Posts
    211

    Re: Code to Make a Lot of Command Buttons On a Userform and name them

    this is what i got so far , 11 command buttons but you can change it (see green comments)
    Please Login or Register  to view this content.
    Last edited by hulpeloos; 10-17-2013 at 04:26 PM. Reason: Naming of command button adjusted

  5. #5
    Forum Contributor
    Join Date
    01-17-2013
    Location
    Belgium
    MS-Off Ver
    Excel 2010
    Posts
    211

    Re: Code to Make a Lot of Command Buttons On a Userform and name them

    @ vbasupernoob
    I still try to work out the names of the buttons with the X Y reference (the - is causing issues)

    how important is this ?
    where the 26th command button in the 26th row is Cmd00 and then
    they go out from that to Cmd2525 in the top right cnr and Cmd-25-25 in the bottom right corner
    This is what i could come up with , but taking it further then 26 it creates name duplicates.
    i must be missing something but don't see it yet.

    Run this one and let me know what you think about it.
    Please Login or Register  to view this content.
    Last edited by hulpeloos; 10-18-2013 at 04:59 AM.

  6. #6
    Forum Contributor
    Join Date
    01-17-2013
    Location
    Belgium
    MS-Off Ver
    Excel 2010
    Posts
    211

    Re: Code to Make a Lot of Command Buttons On a Userform and name them

    Just realised in older versions you might actualy need to insert a blank UserForm prior to running it a first time (unless you already have userform in your workbook.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Align Command Buttons On UserForm
    By jaslake in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 02-28-2014, 01:28 PM
  2. Useform Code - 12 Command Buttons dependant on other command buttons
    By darrenkaye in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 02-20-2013, 10:58 AM
  3. Code for a master command button to change the backcolor of multiple command buttons?
    By panttherm5 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-16-2012, 10:11 PM
  4. Userform - Continue and cancel command buttons code
    By Jessica.Bush in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 09-01-2010, 04:42 PM
  5. Naming command buttons on a UserForm
    By Casey in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 04-07-2006, 11:47 AM

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