commandbutton does not answer

Discussion in 'Excel' started by stefano, Apr 3, 2018.

  1. stefano

    stefano

    Joined:
    Apr 3, 2018
    Messages:
    1
    Likes Received:
    0
    when I activate a specific form I generate the commandbuttons according to the data present in a list with the following code

    Private Sub UserForm_Activate()

    Dim id As Range
    Dim theCombut_ID(1 To 100) As clsButton
    Dim CheckBoxTop As Integer
    CheckBoxTop = 10
    cnt = Sheets(“riepilogo”).Range(“A1”)
    For cont = 1 To cnt
    Set theCombut_ID(cont) = New clsButton
    Set theCombut_ID(cont).cmdButton = Controls.Add(“Forms.CommandButton.1”)
    With theCombut_ID(cont).cmdButton
    .Name = “CB” & cont
    .Value = False
    .Caption = “”
    .Top = CheckBoxTop
    .Left = 12
    .Height = 18
    .Width = 110
    End With
    CheckBoxTop = CheckBoxTop + 19
    cnt = cont + 3
    TEXT_CB = Sheets(“riepilogo”).Range(“A” & cnt)
    C01 = Sheets(“riepilogo”).Range(“A” & cnt).Interior.Color
    theCombut_ID(cont).cmdButton.Caption = Me.Controls(“CB” & cont).Name
    theCombut_ID(cont).cmdButton.BackColor = C01
    Next
    End Sub

    when I write the code at the click of one of the commandbuttons created

    Public Sub CB1_Click()
    Dim rif As Variant
    cnta = Sheets(“riepilogo”).Range(“A1”)
    TEXT_CB = Sheets(“riepilogo”).Range(“A4”)
    rif = Selection.Address
    Range(rif).Value = “ffffff”
    End Sub

    nothing happens and above all with recognizing the commandbutton and I can not understand why

    thank you
    Stefano
     
    stefano, Apr 3, 2018
    #1
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.