G
Guest
Hi all,
In a small area on my worksheet(A1 to A5), I want to achieve the checklist
effect. That means if I double click one of the cell, if the whole area is
empty(without "X"), then the clicked cell appeared "X", if there is already
"X" in this area, then the doubleclick is ignored, if the clicked cell
already is "X" then, "X" will disappear.But without
target.offset(),-1).select, "X" will always appear regardless the logics. The
following is the code:
If CellAddress(target) = I_Zone Or CellAddress(target) = I_Terminal Or
CellAddress(target) = I_Yard Or _
CellAddress(target) = I_Subdivision Or CellAddress(target) =
I_Passenger Then
Dim bCheckMarkAlreadyExist As Boolean
Dim bOldEnableEventState As Boolean
bCheckMarkAlreadyExist = Trim(Range(I_Zone).Value) = "X" Or
Trim(Range(I_Terminal).Value) = "X" Or Trim(Range(I_Yard).Value) = "X" Or _
Trim(Range(I_Subdivision).Value) = "X" Or
Trim(Range(I_Passenger).Value) = "X"
If bCheckMarkAlreadyExist And Trim(target.Value) <> "X" Then ' x, o
MsgBox "Only One Item Can Be Picked Up", vbInformation
Cancel = True
ElseIf bCheckMarkAlreadyExist And Trim(target.Value) = "X" Then '(xo)
bOldEnableEventState = Application.EnableEvents
Application.EnableEvents = False
target.Value = ""
Cancel = False
Application.EnableEvents = bOldEnableEventState
ElseIf Not bCheckMarkAlreadyExist Then
bOldEnableEventState = Application.EnableEvents
Application.EnableEvents = False
target.Value = "X"
Cancel = False
Application.EnableEvents = bOldEnableEventState
End If
target.offset(0, -1).Select ' ??????????????
End If
Clara
In a small area on my worksheet(A1 to A5), I want to achieve the checklist
effect. That means if I double click one of the cell, if the whole area is
empty(without "X"), then the clicked cell appeared "X", if there is already
"X" in this area, then the doubleclick is ignored, if the clicked cell
already is "X" then, "X" will disappear.But without
target.offset(),-1).select, "X" will always appear regardless the logics. The
following is the code:
If CellAddress(target) = I_Zone Or CellAddress(target) = I_Terminal Or
CellAddress(target) = I_Yard Or _
CellAddress(target) = I_Subdivision Or CellAddress(target) =
I_Passenger Then
Dim bCheckMarkAlreadyExist As Boolean
Dim bOldEnableEventState As Boolean
bCheckMarkAlreadyExist = Trim(Range(I_Zone).Value) = "X" Or
Trim(Range(I_Terminal).Value) = "X" Or Trim(Range(I_Yard).Value) = "X" Or _
Trim(Range(I_Subdivision).Value) = "X" Or
Trim(Range(I_Passenger).Value) = "X"
If bCheckMarkAlreadyExist And Trim(target.Value) <> "X" Then ' x, o
MsgBox "Only One Item Can Be Picked Up", vbInformation
Cancel = True
ElseIf bCheckMarkAlreadyExist And Trim(target.Value) = "X" Then '(xo)
bOldEnableEventState = Application.EnableEvents
Application.EnableEvents = False
target.Value = ""
Cancel = False
Application.EnableEvents = bOldEnableEventState
ElseIf Not bCheckMarkAlreadyExist Then
bOldEnableEventState = Application.EnableEvents
Application.EnableEvents = False
target.Value = "X"
Cancel = False
Application.EnableEvents = bOldEnableEventState
End If
target.offset(0, -1).Select ' ??????????????
End If
Clara