View Single Post
  #8   Report Post  
Posted to microsoft.public.excel.misc
Ken G. Ken G. is offline
external usenet poster
 
Posts: 37
Default Toggle cell value

Thanks Stefi. I didn't notice the instruction to move off the cell. When I
put it into my workbook I didn't see that and just typed my active cell in
both places so I missed that clever little move.

BTW, what is the double "II" in the line "Target = IIf(Target = "apples",
"oranges", "apples")? I thought it was a typo and took one out and of course
it threw up an error message.

"Stefi" wrote:

In my solution the macro itself clicks off the cell.

You are welcome! Thanks for the feedback!
Stefi

€˛Ken G.€¯ ezt Ć*rta:

Thanks Steffi and Roanaldo. Both these solutions do what I wanted although
you can't toggle back and forth without first clicking off the cell. I can
put up with that.

"Stefi" wrote:

The closest solution I could achieve:

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Target.Address(False, False) = "A1" Then
Target = IIf(Target = "apples", "oranges", "apples")
Application.EnableEvents = False
Range("A2").Select
Application.EnableEvents = True
End If
End Sub

Regards,
Stefi

€˛Ken G.€¯ ezt Ć*rta:

Is there a way of making a cell active so that it can have two values - say
"apples" and "oranges", and simply clicking on the cell will toggle between
the two values?