Results 1 to 11 of 11

Same code for 26 Buttons

Threaded View

  1. #1
    Registered User
    Join Date
    07-02-2019
    Location
    Mexico
    MS-Off Ver
    365
    Posts
    7

    Question Same code for 26 Buttons

    Hello everybody, thank you for reading, i'm new at this forum. Hope i can help to somebody sometime.

    Now i have a quiestion.
    I have a form with 26 buttons each one has a letter as a caption, ej. A,B,C,D and so on, I use them for call a function that performs a search with the caption as a variable.
    So the code for the 26 buttons is the same except for de caption.

    Private Sub BtnA_Click()
    Letra = Me.BtnA.Caption
    CargaTiendas (Letra)
    End Sub
    
    Private Sub BtnB_Click()
    Letra = Me.BtnB.Caption
    CargaTiendas (Letra)
    End Sub
    is there a way to use just one function or routine that perform this? i do not want to have the same code for 26 buttons. I want some like this


    Private Sub BtnB_Click()  EVENT FOR ALL THE 26 BUTTONS
    Letra = CAPTION OF THE PRESSED BUTTON
    CargaTiendas (Letra)
    End Sub
    Hope this quiestion helps any body else, thank you for reading
    Last edited by Pepe Le Mokko; 07-04-2019 at 11:45 AM.

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Macros with buttons, spin buttons, scroll buttons, etc.
    By qqbbppdd in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 12-12-2013, 09:34 AM
  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. assigning code to buttons
    By crazyhick in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 08-28-2010, 08:02 AM
  4. assigning code to buttons
    By crazyhick in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-28-2010, 06:36 AM
  5. Generic protect/unprotect code through buttons and code?
    By StargateFanFromWork in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 01-02-2006, 03:35 PM
  6. Buttons click in Code
    By Bettergains in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 09-09-2005, 07:05 PM

Tags for this Thread

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