ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Message to Tom Ogilvy regarding SelectionChange (https://www.excelbanter.com/excel-programming/286676-message-tom-ogilvy-regarding-selectionchange.html)

Doug[_9_]

Message to Tom Ogilvy regarding SelectionChange
 
Tom,

Thanks again for the help with the SelectionChange code. One more follow up question if I may. Is this code legal:
----start code-------

Private Sub Worksheet_Change(ByVal Target As Excel.Range)

if Target.Column = 1 then
if Target.Value < Target.offset(0,1).Value then
msgbox "Column 1"
end if
end if

if Target.Column = 5 then
if Target.Value < Target.offset(0,1).Value then
msgbox "Column 5"
end if
end if
End sub

-----end code-----

I have tried this, and only the first "if Target.Column = " statement seems to be recognized. If I run it this way, only targets in column 1 work. If I switch it around, then only targets in column 5 work. And I am not allowed to do more than one "Private Sub Worksheet_Change(ByVal Target As Excel.Range)" statement (I tried this and it told me ambiguous statement). What am I doing wrong? Thanks.

Doug


Doug[_9_]

Message to Tom Ogilvy regarding SelectionChange
 
Never mind. It now appears to be working fine. Go figure

Doug

Tom Ogilvy

Message to Tom Ogilvy regarding SelectionChange
 
Yes, it is legal. Since it is the change event, it only fires when you edit
a cell - not just select it as was the case when you used selectionChange.
But based on your description, Change sounded like the more appropriate
event.

--
Regards,
Tom Ogilvy



Doug wrote in message
...
Never mind. It now appears to be working fine. Go figure.

Doug





All times are GMT +1. The time now is 04:00 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com