Hello All,
I have the problem with passing the variable from macro/module to the worksheet object. Is there anyone who can help? I found somewhere the solution, but I am not able get it at this time.
I need to analyze CBox state only if macro Generuj() is working… / Generuj_isBusy variable. Otherwise it causes lots of unnecessary steps and takes Excel very long time to generate short list of elements.
Macro code:
Sub Generuj_formularz()
Application.ScreenUpdating = False
'***** DEKLARACJE ****
Dim checkbox_cell As String
Dim wiersz_sekcji, wiersz_pytania, i, j As Integer
Dim OKA As Integer
Dim Area As Range
Dim Data As Variant
End Sub
MSExcel Objects:
Private Sub Worksheet_Calculate()
Application.ScreenUpdating = False
Dim CBPrevious As CheckBox
If ActiveSheet.Name = Me.Name And Generuj_isBusy = 1Then
For Each CBox In ActiveSheet.CheckBoxes
If CBPrevious Is Nothing Then
ElseIf CBox.Caption = "NIE" And CBox.Value = 1 Then
pozycja = CBox.TopLeftCell.Row
Cells(pozycja, 1).Font.Strikethrough = True
If CBPrevious.Value = 1 Then
answer = MsgBox("Uwzgl?dnij w kalkulacji: " & Cells(pozycja, 1).Value, vbQuestion + vbYesNo + vbDefaultButton2, "Uwaga")
If answer = vbYes Then
CBox.Value = 0
Cells(CBPrevious.TopLeftCell.Row, CBPrevious.TopLeftCell.Column).Select
Else
CBPrevious.Value = 0
Cells(CBox.TopLeftCell.Row, CBox.TopLeftCell.Column).Select
End If
End If
ElseIf CBox.Caption = "NIE" And CBox.Value <> 1 Then
pozycja = CBox.TopLeftCell.Row
Cells(pozycja, 1).Font.Strikethrough = False
End If
Set CBPrevious = CBox
Next CBox
End If
End Sub
Bookmarks