Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 252
Default what does target.offset(0,-1).select mean here?

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


--
thank you so much for your help
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 695
Default what does target.offset(0,-1).select mean here?

target.offset(0,-1).select means select cell 1 column to left same row

i think this code do what u mean - not sure :-)

Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As
Boolean)
If Intersect(Target, Range("A1:A5")) Is Nothing Then Exit Sub
If Target = "X" Then Target = "": Exit Sub
If Target = "" And Application.WorksheetFunction.CountA(Range("A1:A5" ), "X")
<= 1 Then
Target.Value = "X"
End If
End Sub



"clara" skrev:

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


--
thank you so much for your help

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Target.Offset(0, 36).Value Help Matt Excel Discussion (Misc queries) 0 April 1st 10 05:56 PM
Help in using an Offset in a .Range().Select roblo[_6_] Excel Programming 7 August 26th 05 10:39 PM
Select row (with offset) from VB formula result RAP Excel Programming 1 August 7th 05 09:22 AM
Select and Copy Range using Offset jondorv Excel Programming 1 May 16th 04 05:23 PM
Target Offset? Otto Moehrbach[_3_] Excel Programming 3 July 27th 03 10:39 PM


All times are GMT +1. The time now is 03:30 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"