Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 28
Default Target cell - unexplainable results

My Worksheet_SelectionChange code includes:
....
If (Target.Column = 9 And Target.Offset(0, -4) < "PR") Then
[line2] Target.Offset(0, -1) = StrConv(ActiveCell.Offset(0, -1),
vbProperCase)
ElseIf Target.Column = 9 And Target.Offset(0, -4) = "PR" Then
Target.Offset(0, -1) = StrConv(ActiveCell.Offset(0, -1),
vbUpperCase)
End If
....

Usually works okay, but sometimes (i.e., when Target.column=3), the code
goes to line2 (as if the target.column was 9), and runs line2. What do you
think is up?

TIA


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 860
Default Target cell - unexplainable results

Hi zSplash,

Do you have an On Error Resume Next before your code in hopes of catching
the case where you're in columns A:D? The Offset method will raise an error
when you try to go 4 cells to the left if that will take you to the "left"
of column A. If you did use On Error Resume Next, then that would explain
the behavior - the If statement causes an error, so execution continues
inside the If block. Try an On Error Goto; better yet, check the value of
Cells(Target.Row, 5) instead of using Offset, as you're only checking the
value if the selection is in Column 9 anyway.

--
Regards,

Jake Marx
www.longhead.com

[please keep replies in the newsgroup - email address unmonitored]


zSplash wrote:
My Worksheet_SelectionChange code includes:
...
If (Target.Column = 9 And Target.Offset(0, -4) < "PR") Then
[line2] Target.Offset(0, -1) = StrConv(ActiveCell.Offset(0, -1),
vbProperCase)
ElseIf Target.Column = 9 And Target.Offset(0, -4) = "PR" Then
Target.Offset(0, -1) = StrConv(ActiveCell.Offset(0, -1),
vbUpperCase)
End If
...

Usually works okay, but sometimes (i.e., when Target.column=3), the
code goes to line2 (as if the target.column was 9), and runs line2.
What do you think is up?

TIA


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 21
Default Target cell - unexplainable results

Precisely right, Jake. Thanks so much.

st.

"Jake Marx" wrote in message
...
Hi zSplash,

Do you have an On Error Resume Next before your code in hopes of catching
the case where you're in columns A:D? The Offset method will raise an

error
when you try to go 4 cells to the left if that will take you to the "left"
of column A. If you did use On Error Resume Next, then that would explain
the behavior - the If statement causes an error, so execution continues
inside the If block. Try an On Error Goto; better yet, check the value of
Cells(Target.Row, 5) instead of using Offset, as you're only checking the
value if the selection is in Column 9 anyway.

--
Regards,

Jake Marx
www.longhead.com

[please keep replies in the newsgroup - email address unmonitored]


zSplash wrote:
My Worksheet_SelectionChange code includes:
...
If (Target.Column = 9 And Target.Offset(0, -4) < "PR") Then
[line2] Target.Offset(0, -1) = StrConv(ActiveCell.Offset(0, -1),
vbProperCase)
ElseIf Target.Column = 9 And Target.Offset(0, -4) = "PR" Then
Target.Offset(0, -1) = StrConv(ActiveCell.Offset(0, -1),
vbUpperCase)
End If
...

Usually works okay, but sometimes (i.e., when Target.column=3), the
code goes to line2 (as if the target.column was 9), and runs line2.
What do you think is up?

TIA




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
Unexplainable XIRR #NUM! Error Jay Excel Worksheet Functions 3 April 4th 09 02:16 AM
Target cell reference moves when target is cut and pasted Illya Teideman Excel Discussion (Misc queries) 5 May 31st 07 11:34 AM
Unexplainable Formulas samprince Excel Discussion (Misc queries) 1 June 19th 06 05:06 PM
Unexplainable results from my vlookup Mary-Lou Excel Worksheet Functions 10 May 28th 06 11:17 AM
Unexplainable Duplicate Entries matthews_jd Excel Discussion (Misc queries) 1 March 17th 05 04:31 PM


All times are GMT +1. The time now is 10:23 PM.

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

About Us

"It's about Microsoft Excel"