Merhaba,
Aşağıdaki kodlarla A sütunundaki satırları sonradan userform'a label olarak ekliyorum fakat bunlara ilave olarak label'lerin click olayı ile farklı bir makronun çağrılmasını sağlayabilir miyim? Örneğin ilk olarak eklenen label, B sütununda yazılı olan Module1.hesapla makrosuna gitsin, ikinci eklenen label B sütununda yazan Module3.carp makrosuna gitsin gibi.
Aşağıdaki kodlarla A sütunundaki satırları sonradan userform'a label olarak ekliyorum fakat bunlara ilave olarak label'lerin click olayı ile farklı bir makronun çağrılmasını sağlayabilir miyim? Örneğin ilk olarak eklenen label, B sütununda yazılı olan Module1.hesapla makrosuna gitsin, ikinci eklenen label B sütununda yazan Module3.carp makrosuna gitsin gibi.
Kod:
Private Sub CommandButton1_Click()
Dim x As Integer
Dim c As Integer
Dim a As Integer
Dim b As Control
Dim t As Control
x = 10
c = 3
For a = 3 To Cells(Rows.Count, "A").End(3).Row
Set b = UserForm1.Controls.Add("Forms.Label.1", "Label" & a - 2, True)
With b
.Caption = Cells(a, "A")
.Left = x
.Width = 150
.Top = (13 * c)
' .heigth=
.BackColor = &H8000000F
.TextAlign = fmTextAlignRight
End With
Set t = UserForm1.Controls.Add("Forms.TextBox.1", "TextBox1", True)
With t
.Left = x + b.Left + b.Width
.Width = 150
.Top = 13 * c
End With
c = c + 1
If a = 20 Then x = x + 110: c = 3
Next
End Sub