Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Something's not quite right...
What Im looking for is that when Q12 is selected, the R11 is set to TRUE, when it is selected again, it is set to FALSE. This worked: Private Sub Worksheet_SelectionChange(ByVal Target As Range) If Target.Address = "$Q$12" Then If UCase(Range("R11")) = "TRUE" Then Range("R11") = "FALSE" Else Range("R11") = "TRUE" End If End If Cancel = True End Sub On the Worksheet, I may copy Rows (11-22), sometimes a few times, sometimes a lot. I want the same clicking on its Q cell (Q12, Q24, Q36...) depending on how many times I copy the rows to toggle it's "R" cell (R11, R23, R35) . The loop can end when the A row, (A13, A25, A37) is tested NOT to have a value. Rows are in multiples of 12 Target.Address = "$Q$12" and Range("R11") (BTW A13 is a number) Target.Address = "$Q$24" and Range("R23") (A25 is a number) Target.Address = "$Q$36" and Range("R35") (A37 is a number) Etc I tried the code in the last reply but it does not set the value of R to TRUE/FALSE with the Q cell is selected. I was just hopping to turn this into a loop so that the number of rows I copy can be more dynamic Manually entering the code below works: Private Sub Worksheet_SelectionChange(ByVal Target As Range) If Target.Address = "$Q$12" Then If UCase(Range("R11")) = "TRUE" Then Range("R11") = "FALSE" Else Range("R11") = "TRUE" End If End If If Target.Address = "$Q$24" Then If UCase(Range("R23")) = "TRUE" Then Range("R23") = "FALSE" Else Range("R23") = "TRUE" End If End If If Target.Address = "$Q$36" Then If UCase(Range("R35")) = "TRUE" Then Range("R35") = "FALSE" Else Range("R35") = "TRUE" End If End If If Target.Address = "$Q$48" Then If UCase(Range("R47")) = "TRUE" Then Range("R47") = "FALSE" Else Range("R47") = "TRUE" End If End If If Target.Address = "$Q$60" Then If UCase(Range("R59")) = "TRUE" Then Range("R59") = "FALSE" Else Range("R59") = "TRUE" End If End If Cancel = True End Sub ,,,etc,,, |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Setting Multiple Variables with a loop | Excel Discussion (Misc queries) | |||
solved problem | Excel Worksheet Functions | |||
Excel VBA - changing variables during a loop | Excel Programming | |||
Newbie. Please help me find a loop solution | Excel Programming | |||
Newbie. Please help me find a loop solution | Excel Programming |