ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Cell Movement - Not Working Correctly (https://www.excelbanter.com/excel-programming/357059-cell-movement-not-working-correctly.html)

Paige

Cell Movement - Not Working Correctly
 
I have the following code:

Private Sub Worksheet_Change(ByVal Target As Range)
ActiveSheet.Unprotect Password:="test"
If Target.Address = "$C$65" Then
If Target.Value 0 Then
Rows("66:77").Hidden = False
Range("$C$72").Select
Else
Rows("66:77").Hidden = True
Range("C72:H76").ClearContents
Range("C79").Select
End If
End If
ActiveSheet.Protect Password:="test"

When I enter a value of 1 or more in C65, it follows the code and unhides
rows 66:77 and takes me to C72, which it should. But then when I enter a
numeric value in C72 and hit enter, my cursor goes to C81, which is no where
in the above code or anywhere else in the rest of my code. After going to
C81, I can move the cursor back to C72, enter a numeric value again and hit
enter, and it reacts correctly by taking me to D72 (versus C81).

I've checked all my other code and there is nothing that references any of
these cells/rows other than the above. None of the cells are locked either.
Can someone advise what I'm doing wrong here; this is driving me CRAZY!!!!

Don Guillett

Cell Movement - Not Working Correctly
 
I tried your code, without protection, and it worked as desired.

--
Don Guillett
SalesAid Software

"Paige" wrote in message
...
I have the following code:

Private Sub Worksheet_Change(ByVal Target As Range)
ActiveSheet.Unprotect Password:="test"
If Target.Address = "$C$65" Then
If Target.Value 0 Then
Rows("66:77").Hidden = False
Range("$C$72").Select
Else
Rows("66:77").Hidden = True
Range("C72:H76").ClearContents
Range("C79").Select
End If
End If
ActiveSheet.Protect Password:="test"

When I enter a value of 1 or more in C65, it follows the code and unhides
rows 66:77 and takes me to C72, which it should. But then when I enter a
numeric value in C72 and hit enter, my cursor goes to C81, which is no
where
in the above code or anywhere else in the rest of my code. After going to
C81, I can move the cursor back to C72, enter a numeric value again and
hit
enter, and it reacts correctly by taking me to D72 (versus C81).

I've checked all my other code and there is nothing that references any of
these cells/rows other than the above. None of the cells are locked
either.
Can someone advise what I'm doing wrong here; this is driving me CRAZY!!!!




Paige

Cell Movement - Not Working Correctly
 
Thanks, Don. It does work right without protection, but why would it not
work correctly with protection? That is what is bugging me; I thought I had
locked some cells, but that wasn't the case. I need the worksheet to be
protected, so this is why it's a problem.

"Don Guillett" wrote:

I tried your code, without protection, and it worked as desired.

--
Don Guillett
SalesAid Software

"Paige" wrote in message
...
I have the following code:

Private Sub Worksheet_Change(ByVal Target As Range)
ActiveSheet.Unprotect Password:="test"
If Target.Address = "$C$65" Then
If Target.Value 0 Then
Rows("66:77").Hidden = False
Range("$C$72").Select
Else
Rows("66:77").Hidden = True
Range("C72:H76").ClearContents
Range("C79").Select
End If
End If
ActiveSheet.Protect Password:="test"

When I enter a value of 1 or more in C65, it follows the code and unhides
rows 66:77 and takes me to C72, which it should. But then when I enter a
numeric value in C72 and hit enter, my cursor goes to C81, which is no
where
in the above code or anywhere else in the rest of my code. After going to
C81, I can move the cursor back to C72, enter a numeric value again and
hit
enter, and it reacts correctly by taking me to D72 (versus C81).

I've checked all my other code and there is nothing that references any of
these cells/rows other than the above. None of the cells are locked
either.
Can someone advise what I'm doing wrong here; this is driving me CRAZY!!!!






All times are GMT +1. The time now is 12:52 AM.

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