This should do it

Private Sub Worksheet_SelectionChange(ByVal Target As Range)

    If Target.Address(0, 0) = "G15" Then
        Target.Value = Abs(CLng(Not -Target.Value))
    End If

End Sub

Use a conditional format for coloring the cell.

If you do not want to add a conditional format (which is faster than VBA by
the way), and do the coloring also through VBA, then just add the following
line within the If End IF statement in the VBA above.

Target.Interior.ColorIndex = 4 - Target.Value

Regards,

Sam Mathai Chacko

On Fri, Oct 14, 2011 at 6:09 PM, dguillett1 <dguille...@gmail.com> wrote:

>   Right click sheet tab>view code>copy/paste this to make the changes in
> col G
>
> Private Sub Worksheet_SelectionChange(ByVal Target As Range)
> If Target.Column <> 7 Or Target.Count > 1 Then Exit Sub
> If Target = 1 Then
> Target = 0
> Target.Interior.ColorIndex = 4
> Else
> Target = 1
> Target.Interior.ColorIndex = 3
> End If
> End Sub
>
> Don Guillett
> SalesAid Software
> dguille...@gmail.com
>
>  *From:* Cab Boose <swch...@gmail.com>
> *Sent:* Friday, October 14, 2011 2:33 AM
> *To:* excel-macros@googlegroups.com
> *Subject:* $$Excel-Macros$$ Toggle a Cell value
>
>  Hi eveyrone
>
> See attached sheet.
>
> For a 12 volt motor speed direction, Forward or Reverse  I want to have a
> value of a cell to toggle back and forth between 0 and 1 and cell color also
> to change each time between green and red.
>
> Prefer to use a cell than use a toggle button, unless a toggle button can
> change colors etc and the value of 0 or 1  from the toggle button can be
> used to export etc
>
> Your comments would be appreciated.
>
> Charlie Harris
> --
>
> ----------------------------------------------------------------------------------
> Some important links for excel users:
> 1. Follow us on TWITTER for tips tricks and links :
> http://twitter.com/exceldailytip
> 2. Join our LinkedIN group @ http://www.linkedin.com/groups?gid=1871310
> 3. Excel tutorials at http://www.excel-macros.blogspot.com
> 4. Learn VBA Macros at http://www.quickvba.blogspot.com
> 5. Excel Tips and Tricks at http://exceldailytip.blogspot.com
>
> To post to this group, send email to excel-macros@googlegroups.com
>
> <><><><><><><><><><><><><><><><><><><><><><>
> Like our page on facebook , Just follow below link
> http://www.facebook.com/discussexcel
>
> --
>
> ----------------------------------------------------------------------------------
> Some important links for excel users:
> 1. Follow us on TWITTER for tips tricks and links :
> http://twitter.com/exceldailytip
> 2. Join our LinkedIN group @ http://www.linkedin.com/groups?gid=1871310
> 3. Excel tutorials at http://www.excel-macros.blogspot.com
> 4. Learn VBA Macros at http://www.quickvba.blogspot.com
> 5. Excel Tips and Tricks at http://exceldailytip.blogspot.com
>
> To post to this group, send email to excel-macros@googlegroups.com
>
> <><><><><><><><><><><><><><><><><><><><><><>
> Like our page on facebook , Just follow below link
> http://www.facebook.com/discussexcel
>



-- 
Sam Mathai Chacko

-- 
----------------------------------------------------------------------------------
Some important links for excel users:
1. Follow us on TWITTER for tips tricks and links : 
http://twitter.com/exceldailytip
2. Join our LinkedIN group @ http://www.linkedin.com/groups?gid=1871310
3. Excel tutorials at http://www.excel-macros.blogspot.com
4. Learn VBA Macros at http://www.quickvba.blogspot.com
5. Excel Tips and Tricks at http://exceldailytip.blogspot.com
 
To post to this group, send email to excel-macros@googlegroups.com

<><><><><><><><><><><><><><><><><><><><><><>
Like our page on facebook , Just follow below link
http://www.facebook.com/discussexcel

Attachment: CellToggle.xls
Description: MS-Excel spreadsheet

Reply via email to