![]() |
Execute on Cell Change - Problem
Hello, folks:
I'm trying to execute a series of code steps based on changes to ranges of cells. I have used this code before, but for some reason it's not working now and I can't spot why. Basically, I want to change the value of cells in a column AB (28) of my worksheet if any cell in ranges D8:F1000 or V8:X1000 change. Here is the code. Can anyone spot anything obvious? Private Sub Worksheet_Change(ByVal Target As Excel.Range) Dim myRow&, myCol& myRow = Target.Row myCol = Target.Column If myRow 7 And myRow < 1001 Then If (myCol 6 And MyCOL < 9) Or _ (myCol 21 And MyCOL < 25) Then {code steps here, which do a row-by-row evaluation of the contents of the target ranges and put a string of text (which varies depending upon the contents of the targets) in the corresponding row in column 28.} End If 'myCol End If 'myRow I commented out the code above and tried it with a command button and it works fine, so I know the code steps are not the problem. Thoughts? Thanks in advance. MARTY |
Execute on Cell Change - Problem
? Range("D1").Column
4 ? Range("F1").Column 6 so If (myCol 6 And MyCOL < 9) Or _ should be If (myCol 3 And MyCOL < 7) Or _ -- Regards, Tom Ogilvy "Marty" wrote in message ... Hello, folks: I'm trying to execute a series of code steps based on changes to ranges of cells. I have used this code before, but for some reason it's not working now and I can't spot why. Basically, I want to change the value of cells in a column AB (28) of my worksheet if any cell in ranges D8:F1000 or V8:X1000 change. Here is the code. Can anyone spot anything obvious? Private Sub Worksheet_Change(ByVal Target As Excel.Range) Dim myRow&, myCol& myRow = Target.Row myCol = Target.Column If myRow 7 And myRow < 1001 Then If (myCol 6 And MyCOL < 9) Or _ (myCol 21 And MyCOL < 25) Then {code steps here, which do a row-by-row evaluation of the contents of the target ranges and put a string of text (which varies depending upon the contents of the targets) in the corresponding row in column 28.} End If 'myCol End If 'myRow I commented out the code above and tried it with a command button and it works fine, so I know the code steps are not the problem. Thoughts? Thanks in advance. MARTY |
Execute on Cell Change - Problem
That did it. Thanks so much, Tom. I figued it was something simple I was
overlooking. {Note to self: D = 4, D<6 . . .} "Tom Ogilvy" wrote: ? Range("D1").Column 4 ? Range("F1").Column 6 so If (myCol 6 And MyCOL < 9) Or _ should be If (myCol 3 And MyCOL < 7) Or _ -- Regards, Tom Ogilvy "Marty" wrote in message ... Hello, folks: I'm trying to execute a series of code steps based on changes to ranges of cells. I have used this code before, but for some reason it's not working now and I can't spot why. Basically, I want to change the value of cells in a column AB (28) of my worksheet if any cell in ranges D8:F1000 or V8:X1000 change. Here is the code. Can anyone spot anything obvious? Private Sub Worksheet_Change(ByVal Target As Excel.Range) Dim myRow&, myCol& myRow = Target.Row myCol = Target.Column If myRow 7 And myRow < 1001 Then If (myCol 6 And MyCOL < 9) Or _ (myCol 21 And MyCOL < 25) Then {code steps here, which do a row-by-row evaluation of the contents of the target ranges and put a string of text (which varies depending upon the contents of the targets) in the corresponding row in column 28.} End If 'myCol End If 'myRow I commented out the code above and tried it with a command button and it works fine, so I know the code steps are not the problem. Thoughts? Thanks in advance. MARTY |
All times are GMT +1. The time now is 07:25 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com