Страница: 1 | 2 |
Вопрос: Динамическое заполнение процедуры Click
Добавлено: 01.04.10 15:17
Автор вопроса: Dimoney | ICQ: 226787316
Приветствую...
Подскажите, динамически создаю на листе N-е кол-во чек-боксов. При выборе каждый выполняет одно и то же действие. Можно ли (как) макросом прописать код в процедуру Check_Box(i).Click(), что-то типа Cells(i, 7).value = i ?
Ответить
Номер ответа: 5Автор ответа: VβÐUηìt
Вопросов: 246Ответов: 3333
Web-сайт: смекаешь.рф Профиль | | #5
Добавлено: 01.04.10 20:00
Вот улучшенный вариант: можно обращаться к свойствам чекбоксов. Для этого есть массив MyCheckBox(номер):
Private Sub CheckBox_Click(sender As CheckBox, Index As Long )
End Sub
Private Sub CheckBox1_Click()
Call CheckBox_Click(CheckBox1, 1)
End Sub
Private Sub CheckBox2_Click()
Call CheckBox_Click(CheckBox2, 2)
End Sub
Private Sub CheckBox3_Click()
Call CheckBox_Click(CheckBox3, 3)
End Sub
Private Sub CheckBox4_Click()
Call CheckBox_Click(CheckBox4, 4)
End Sub
Private Sub CheckBox5_Click()
Call CheckBox_Click(CheckBox5, 5)
End Sub
Private Sub CheckBox6_Click()
Call CheckBox_Click(CheckBox6, 6)
End Sub
Private Sub CheckBox7_Click()
Call CheckBox_Click(CheckBox7, 7)
End Sub
Private Sub CheckBox8_Click()
Call CheckBox_Click(CheckBox8, 8)
End Sub
Private Sub CheckBox9_Click()
Call CheckBox_Click(CheckBox9, 9)
End Sub
Private Sub CheckBox10_Click()
Call CheckBox_Click(CheckBox10, 10)
End Sub
Private Sub CheckBox11_Click()
Call CheckBox_Click(CheckBox11, 11)
End Sub
Private Sub CheckBox12_Click()
Call CheckBox_Click(CheckBox12, 12)
End Sub
Private Sub CheckBox13_Click()
Call CheckBox_Click(CheckBox13, 13)
End Sub
Private Sub CheckBox14_Click()
Call CheckBox_Click(CheckBox14, 14)
End Sub
Private Sub CheckBox15_Click()
Call CheckBox_Click(CheckBox15, 15)
End Sub
Private Sub CheckBox16_Click()
Call CheckBox_Click(CheckBox16, 16)
End Sub
Private Sub CheckBox17_Click()
Call CheckBox_Click(CheckBox17, 17)
End Sub
Private Sub CheckBox18_Click()
Call CheckBox_Click(CheckBox18, 18)
End Sub
Private Sub CheckBox19_Click()
Call CheckBox_Click(CheckBox19, 19)
End Sub
Private Sub CheckBox20_Click()
Call CheckBox_Click(CheckBox20, 20)
End Sub
Private Sub CheckBox21_Click()
Call CheckBox_Click(CheckBox21, 21)
End Sub
Private Sub CheckBox22_Click()
Call CheckBox_Click(CheckBox22, 22)
End Sub
Private Sub CheckBox23_Click()
Call CheckBox_Click(CheckBox23, 23)
End Sub
Private Sub CheckBox24_Click()
Call CheckBox_Click(CheckBox24, 24)
End Sub
Private Sub CheckBox25_Click()
Call CheckBox_Click(CheckBox25, 25)
End Sub
Private Sub CheckBox26_Click()
Call CheckBox_Click(CheckBox26, 26)
End Sub
Private Sub CheckBox27_Click()
Call CheckBox_Click(CheckBox27, 27)
End Sub
Private Sub CheckBox28_Click()
Call CheckBox_Click(CheckBox28, 28)
End Sub
Private Sub CheckBox29_Click()
Call CheckBox_Click(CheckBox29, 29)
End Sub
Private Sub CheckBox30_Click()
Call CheckBox_Click(CheckBox30, 30)
End Sub
Private Sub CheckBox31_Click()
Call CheckBox_Click(CheckBox31, 31)
End Sub
Private Sub CheckBox32_Click()
Call CheckBox_Click(CheckBox32, 32)
End Sub
Private Sub CheckBox33_Click()
Call CheckBox_Click(CheckBox33, 33)
End Sub
Private Sub CheckBox34_Click()
Call CheckBox_Click(CheckBox34, 34)
End Sub
Private Sub CheckBox35_Click()
Call CheckBox_Click(CheckBox35, 35)
End Sub
Private Sub CheckBox36_Click()
Call CheckBox_Click(CheckBox36, 36)
End Sub
Private Sub CheckBox37_Click()
Call CheckBox_Click(CheckBox37, 37)
End Sub
Private Sub CheckBox38_Click()
Call CheckBox_Click(CheckBox38, 38)
End Sub
Private Sub CheckBox39_Click()
Call CheckBox_Click(CheckBox39, 39)
End Sub
Private Sub CheckBox40_Click()
Call CheckBox_Click(CheckBox40, 40)
End Sub
Private Sub CheckBox41_Click()
Call CheckBox_Click(CheckBox41, 41)
End Sub
Private Sub CheckBox42_Click()
Call CheckBox_Click(CheckBox42, 42)
End Sub
Private Sub CheckBox43_Click()
Call CheckBox_Click(CheckBox43, 43)
End Sub
Private Sub CheckBox44_Click()
Call CheckBox_Click(CheckBox44, 44)
End Sub
Private Sub CheckBox45_Click()
Call CheckBox_Click(CheckBox45, 45)
End Sub
Private Sub CheckBox46_Click()
Call CheckBox_Click(CheckBox46, 46)
End Sub
Private Sub CheckBox47_Click()
Call CheckBox_Click(CheckBox47, 47)
End Sub
Private Sub CheckBox48_Click()
Call CheckBox_Click(CheckBox48, 48)
End Sub
Private Sub CheckBox49_Click()
Call CheckBox_Click(CheckBox49, 49)
End Sub
Private Sub CheckBox50_Click()
Call CheckBox_Click(CheckBox50, 50)
End Sub
Private Sub CheckBox51_Click()
Call CheckBox_Click(CheckBox51, 51)
End Sub
Private Sub CheckBox52_Click()
Call CheckBox_Click(CheckBox52, 52)
End Sub
Private Sub CheckBox53_Click()
Call CheckBox_Click(CheckBox53, 53)
End Sub
Private Sub CheckBox54_Click()
Call CheckBox_Click(CheckBox54, 54)
End Sub
Private Sub CheckBox55_Click()
Call CheckBox_Click(CheckBox55, 55)
End Sub
Private Sub CheckBox56_Click()
Call CheckBox_Click(CheckBox56, 56)
End Sub
Private Sub CheckBox57_Click()
Call CheckBox_Click(CheckBox57, 57)
End Sub
Private Sub CheckBox58_Click()
Call CheckBox_Click(CheckBox58, 58)
End Sub
Private Sub CheckBox59_Click()
Call CheckBox_Click(CheckBox59, 59)
End Sub
Private Sub CheckBox60_Click()
Call CheckBox_Click(CheckBox60, 60)
End Sub
Private Sub CheckBox61_Click()
Call CheckBox_Click(CheckBox61, 61)
End Sub
Private Sub CheckBox62_Click()
Call CheckBox_Click(CheckBox62, 62)
End Sub
Private Sub CheckBox63_Click()
Call CheckBox_Click(CheckBox63, 63)
End Sub
Private Sub CheckBox64_Click()
Call CheckBox_Click(CheckBox64, 64)
End Sub
Private Sub CheckBox65_Click()
Call CheckBox_Click(CheckBox65, 65)
End Sub
Private Sub CheckBox66_Click()
Call CheckBox_Click(CheckBox66, 66)
End Sub
Private Sub CheckBox67_Click()
Call CheckBox_Click(CheckBox67, 67)
End Sub
Private Sub CheckBox68_Click()
Call CheckBox_Click(CheckBox68, 68)
End Sub
Private Sub CheckBox69_Click()
Call CheckBox_Click(CheckBox69, 69)
End Sub
Private Sub CheckBox70_Click()
Call CheckBox_Click(CheckBox70, 70)
End Sub
Private Sub CheckBox71_Click()
Call CheckBox_Click(CheckBox71, 71)
End Sub
Private Sub CheckBox72_Click()
Call CheckBox_Click(CheckBox72, 72)
End Sub
Private Sub CheckBox73_Click()
Call CheckBox_Click(CheckBox73, 73)
End Sub
Private Sub CheckBox74_Click()
Call CheckBox_Click(CheckBox74, 74)
End Sub
Private Sub CheckBox75_Click()
Call CheckBox_Click(CheckBox75, 75)
End Sub
Private Sub CheckBox76_Click()
Call CheckBox_Click(CheckBox76, 76)
End Sub
Private Sub CheckBox77_Click()
Call CheckBox_Click(CheckBox77, 77)
End Sub
Private Sub CheckBox78_Click()
Call CheckBox_Click(CheckBox78, 78)
End Sub
Private Sub CheckBox79_Click()
Call CheckBox_Click(CheckBox79, 79)
End Sub
Private Sub CheckBox80_Click()
Call CheckBox_Click(CheckBox80, 80)
End Sub
Private Sub CheckBox81_Click()
Call CheckBox_Click(CheckBox81, 81)
End Sub
Private Sub CheckBox82_Click()
Call CheckBox_Click(CheckBox82, 82)
End Sub
Private Sub CheckBox83_Click()
Call CheckBox_Click(CheckBox83, 83)
End Sub
Private Sub CheckBox84_Click()
Call CheckBox_Click(CheckBox84, 84)
End Sub
Private Sub CheckBox85_Click()
Call CheckBox_Click(CheckBox85, 85)
End Sub
Private Sub CheckBox86_Click()
Call CheckBox_Click(CheckBox86, 86)
End Sub
Private Sub CheckBox87_Click()
Call CheckBox_Click(CheckBox87, 87)
End Sub
Private Sub CheckBox88_Click()
Call CheckBox_Click(CheckBox88, 88)
End Sub
Private Sub CheckBox89_Click()
Call CheckBox_Click(CheckBox89, 89)
End Sub
Private Sub CheckBox90_Click()
Call CheckBox_Click(CheckBox90, 90)
End Sub
Private Sub CheckBox91_Click()
Call CheckBox_Click(CheckBox91, 91)
End Sub
Private Sub CheckBox92_Click()
Call CheckBox_Click(CheckBox92, 92)
End Sub
Private Sub CheckBox93_Click()
Call CheckBox_Click(CheckBox93, 93)
End Sub
Private Sub CheckBox94_Click()
Call CheckBox_Click(CheckBox94, 94)
End Sub
Private Sub CheckBox95_Click()
Call CheckBox_Click(CheckBox95, 95)
End Sub
Private Sub CheckBox96_Click()
Call CheckBox_Click(CheckBox96, 96)
End Sub
Private Sub CheckBox97_Click()
Call CheckBox_Click(CheckBox97, 97)
End Sub
Private Sub CheckBox98_Click()
Call CheckBox_Click(CheckBox98, 98)
End Sub
Private Sub CheckBox99_Click()
Call CheckBox_Click(CheckBox99, 99)
End Sub
Private Sub CheckBox100_Click()
Call CheckBox_Click(CheckBox100, 100)
End Sub
Public Property Get MyCheckBox(index as Long ) As CheckBox
If index = 1 Then MyCheckBox = CheckBox1: Exit Sub
If index = 2 Then MyCheckBox = CheckBox2: Exit Sub
If index = 3 Then MyCheckBox = CheckBox3: Exit Sub
If index = 4 Then MyCheckBox = CheckBox4: Exit Sub
If index = 5 Then MyCheckBox = CheckBox5: Exit Sub
If index = 6 Then MyCheckBox = CheckBox6: Exit Sub
If index = 7 Then MyCheckBox = CheckBox7: Exit Sub
If index = 8 Then MyCheckBox = CheckBox8: Exit Sub
If index = 9 Then MyCheckBox = CheckBox9: Exit Sub
If index = 10 Then MyCheckBox = CheckBox10: Exit Sub
If index = 11 Then MyCheckBox = CheckBox11: Exit Sub
If index = 12 Then MyCheckBox = CheckBox12: Exit Sub
If index = 13 Then MyCheckBox = CheckBox13: Exit Sub
If index = 14 Then MyCheckBox = CheckBox14: Exit Sub
If index = 15 Then MyCheckBox = CheckBox15: Exit Sub
If index = 16 Then MyCheckBox = CheckBox16: Exit Sub
If index = 17 Then MyCheckBox = CheckBox17: Exit Sub
If index = 18 Then MyCheckBox = CheckBox18: Exit Sub
If index = 19 Then MyCheckBox = CheckBox19: Exit Sub
If index = 20 Then MyCheckBox = CheckBox20: Exit Sub
If index = 21 Then MyCheckBox = CheckBox21: Exit Sub
If index = 22 Then MyCheckBox = CheckBox22: Exit Sub
If index = 23 Then MyCheckBox = CheckBox23: Exit Sub
If index = 24 Then MyCheckBox = CheckBox24: Exit Sub
If index = 25 Then MyCheckBox = CheckBox25: Exit Sub
If index = 26 Then MyCheckBox = CheckBox26: Exit Sub
If index = 27 Then MyCheckBox = CheckBox27: Exit Sub
If index = 28 Then MyCheckBox = CheckBox28: Exit Sub
If index = 29 Then MyCheckBox = CheckBox29: Exit Sub
If index = 30 Then MyCheckBox = CheckBox30: Exit Sub
If index = 31 Then MyCheckBox = CheckBox31: Exit Sub
If index = 32 Then MyCheckBox = CheckBox32: Exit Sub
If index = 33 Then MyCheckBox = CheckBox33: Exit Sub
If index = 34 Then MyCheckBox = CheckBox34: Exit Sub
If index = 35 Then MyCheckBox = CheckBox35: Exit Sub
If index = 36 Then MyCheckBox = CheckBox36: Exit Sub
If index = 37 Then MyCheckBox = CheckBox37: Exit Sub
If index = 38 Then MyCheckBox = CheckBox38: Exit Sub
If index = 39 Then MyCheckBox = CheckBox39: Exit Sub
If index = 40 Then MyCheckBox = CheckBox40: Exit Sub
If index = 41 Then MyCheckBox = CheckBox41: Exit Sub
If index = 42 Then MyCheckBox = CheckBox42: Exit Sub
If index = 43 Then MyCheckBox = CheckBox43: Exit Sub
If index = 44 Then MyCheckBox = CheckBox44: Exit Sub
If index = 45 Then MyCheckBox = CheckBox45: Exit Sub
If index = 46 Then MyCheckBox = CheckBox46: Exit Sub
If index = 47 Then MyCheckBox = CheckBox47: Exit Sub
If index = 48 Then MyCheckBox = CheckBox48: Exit Sub
If index = 49 Then MyCheckBox = CheckBox49: Exit Sub
If index = 50 Then MyCheckBox = CheckBox50: Exit Sub
If index = 51 Then MyCheckBox = CheckBox51: Exit Sub
If index = 52 Then MyCheckBox = CheckBox52: Exit Sub
If index = 53 Then MyCheckBox = CheckBox53: Exit Sub
If index = 54 Then MyCheckBox = CheckBox54: Exit Sub
If index = 55 Then MyCheckBox = CheckBox55: Exit Sub
If index = 56 Then MyCheckBox = CheckBox56: Exit Sub
If index = 57 Then MyCheckBox = CheckBox57: Exit Sub
If index = 58 Then MyCheckBox = CheckBox58: Exit Sub
If index = 59 Then MyCheckBox = CheckBox59: Exit Sub
If index = 60 Then MyCheckBox = CheckBox60: Exit Sub
If index = 61 Then MyCheckBox = CheckBox61: Exit Sub
If index = 62 Then MyCheckBox = CheckBox62: Exit Sub
If index = 63 Then MyCheckBox = CheckBox63: Exit Sub
If index = 64 Then MyCheckBox = CheckBox64: Exit Sub
If index = 65 Then MyCheckBox = CheckBox65: Exit Sub
If index = 66 Then MyCheckBox = CheckBox66: Exit Sub
If index = 67 Then MyCheckBox = CheckBox67: Exit Sub
If index = 68 Then MyCheckBox = CheckBox68: Exit Sub
If index = 69 Then MyCheckBox = CheckBox69: Exit Sub
If index = 70 Then MyCheckBox = CheckBox70: Exit Sub
If index = 71 Then MyCheckBox = CheckBox71: Exit Sub
If index = 72 Then MyCheckBox = CheckBox72: Exit Sub
If index = 73 Then MyCheckBox = CheckBox73: Exit Sub
If index = 74 Then MyCheckBox = CheckBox74: Exit Sub
If index = 75 Then MyCheckBox = CheckBox75: Exit Sub
If index = 76 Then MyCheckBox = CheckBox76: Exit Sub
If index = 77 Then MyCheckBox = CheckBox77: Exit Sub
If index = 78 Then MyCheckBox = CheckBox78: Exit Sub
If index = 79 Then MyCheckBox = CheckBox79: Exit Sub
If index = 80 Then MyCheckBox = CheckBox80: Exit Sub
If index = 81 Then MyCheckBox = CheckBox81: Exit Sub
If index = 82 Then MyCheckBox = CheckBox82: Exit Sub
If index = 83 Then MyCheckBox = CheckBox83: Exit Sub
If index = 84 Then MyCheckBox = CheckBox84: Exit Sub
If index = 85 Then MyCheckBox = CheckBox85: Exit Sub
If index = 86 Then MyCheckBox = CheckBox86: Exit Sub
If index = 87 Then MyCheckBox = CheckBox87: Exit Sub
If index = 88 Then MyCheckBox = CheckBox88: Exit Sub
If index = 89 Then MyCheckBox = CheckBox89: Exit Sub
If index = 90 Then MyCheckBox = CheckBox90: Exit Sub
If index = 91 Then MyCheckBox = CheckBox91: Exit Sub
If index = 92 Then MyCheckBox = CheckBox92: Exit Sub
If index = 93 Then MyCheckBox = CheckBox93: Exit Sub
If index = 94 Then MyCheckBox = CheckBox94: Exit Sub
If index = 95 Then MyCheckBox = CheckBox95: Exit Sub
If index = 96 Then MyCheckBox = CheckBox96: Exit Sub
If index = 97 Then MyCheckBox = CheckBox97: Exit Sub
If index = 98 Then MyCheckBox = CheckBox98: Exit Sub
If index = 99 Then MyCheckBox = CheckBox99: Exit Sub
If index = 100 Then MyCheckBox = CheckBox100: Exit Sub
End Property
Public Property Set MyCheckBox(Index As Long , Check As CheckBox)
End Property
Ответить
Номер ответа: 10Автор ответа: GDK
Вопросов: 13Ответов: 348
Профиль | | #10
Добавлено: 05.04.10 10:26
Ну тогда гугли Microsoft ScriptControl
Зачем???
Макрос должен создать чекбокс, и
добавить к проекту процедуру обработки события клик . Т.е. надо не прописать код в процедуру Click, а добавить саму процедуру
Private Sub CheckBoxN_Click()
...
End Sub
Это можно, только не помню как. Посмотри в сторону объекта VBE кажется.
Хотя может быть можно и редактировать код существующих процедур и даже построчно.
Ответить
Страница: 1 | 2 |
Поиск по форуму