Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 396
Default "Toggle Switch" help needed

Hi all, this is probably so easy but it is eluding me !!

I need to make an edit button that inserts a 1 in A1 and the caption
then changes to "DONE" and when clicked again it removes the 1 from A1
and the caption then changes back to "EDIT"


Best regards,

Les Stout

*** Sent via Developersdex http://www.developersdex.com ***
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 735
Default "Toggle Switch" help needed

Private Sub CommandButton1_Click()
If CommandButton1.Caption = "Done" Then
CommandButton1.Caption = "Edit"
Range("A1") = ""
Else
CommandButton1.Caption = "Done"
Range("A1") = 1
End If
End Sub

--

Regards,
Nigel




"Les Stout" wrote in message
...
Hi all, this is probably so easy but it is eluding me !!

I need to make an edit button that inserts a 1 in A1 and the caption
then changes to "DONE" and when clicked again it removes the 1 from A1
and the caption then changes back to "EDIT"


Best regards,

Les Stout

*** Sent via Developersdex
http://www.developersdex.com ***

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,202
Default "Toggle Switch" help needed

Maybe this?

Private Sub CommandButton1_Click()
With CommandButton1
If .Caption = "DONE" Then
ActiveSheet.Range("A1").Value = ""
.Caption = "EDIT"
Else
ActiveSheet.Range("A1").Value = "1"
.Caption = "DONE"
End If
End With
End Sub

Rick



"Les Stout" wrote in message
...
Hi all, this is probably so easy but it is eluding me !!

I need to make an edit button that inserts a 1 in A1 and the caption
then changes to "DONE" and when clicked again it removes the 1 from A1
and the caption then changes back to "EDIT"


Best regards,

Les Stout

*** Sent via Developersdex http://www.developersdex.com ***


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,501
Default "Toggle Switch" help needed

les,

I'm not sure what you mean by an 'Edit Button' so this is a 'Toggle Button'
from the Control toolbox.

Set the caption to 'Edit' right click the button, view code and paste this in

Private Sub ToggleButton1_Click()
With ToggleButton1
If .Caption = "Edit" Then
Range("A1").Value = 1
.Caption = "Done"
Else
Range("A1").Value = ""
.Caption = "Edit"
End If
End With
End Sub


Mike

"Les Stout" wrote:

Hi all, this is probably so easy but it is eluding me !!

I need to make an edit button that inserts a 1 in A1 and the caption
then changes to "DONE" and when clicked again it removes the 1 from A1
and the caption then changes back to "EDIT"


Best regards,

Les Stout

*** Sent via Developersdex http://www.developersdex.com ***

  #5   Report Post  
Posted to microsoft.public.excel.programming
Les Les is offline
external usenet poster
 
Posts: 240
Default "Toggle Switch" help needed

Thanks so much for the replies, all great
--
Les


"Mike H" wrote:

les,

I'm not sure what you mean by an 'Edit Button' so this is a 'Toggle Button'
from the Control toolbox.

Set the caption to 'Edit' right click the button, view code and paste this in

Private Sub ToggleButton1_Click()
With ToggleButton1
If .Caption = "Edit" Then
Range("A1").Value = 1
.Caption = "Done"
Else
Range("A1").Value = ""
.Caption = "Edit"
End If
End With
End Sub


Mike

"Les Stout" wrote:

Hi all, this is probably so easy but it is eluding me !!

I need to make an edit button that inserts a 1 in A1 and the caption
then changes to "DONE" and when clicked again it removes the 1 from A1
and the caption then changes back to "EDIT"


Best regards,

Les Stout

*** Sent via Developersdex http://www.developersdex.com ***



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,202
Default "Toggle Switch" help needed

I would **not** use the following in production code... I'm posting it more
to get the reader to see there are ways to "think outside the box" when it
comes to coding (and, also, as an exercise for the reader to decipher why it
works<g)...

Private Sub CommandButton1_Click()
Range("A1").Value = String(1 - Val(Range("A1").Value), "1")
CommandButton1.Caption = Split("EDIT DONE")(Val(Range("A1").Value))
End Sub

Rick


"Rick Rothstein (MVP - VB)" wrote in
message ...
Maybe this?

Private Sub CommandButton1_Click()
With CommandButton1
If .Caption = "DONE" Then
ActiveSheet.Range("A1").Value = ""
.Caption = "EDIT"
Else
ActiveSheet.Range("A1").Value = "1"
.Caption = "DONE"
End If
End With
End Sub

Rick



"Les Stout" wrote in message
...
Hi all, this is probably so easy but it is eluding me !!

I need to make an edit button that inserts a 1 in A1 and the caption
then changes to "DONE" and when clicked again it removes the 1 from A1
and the caption then changes back to "EDIT"


Best regards,

Les Stout

*** Sent via Developersdex http://www.developersdex.com ***



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Shortcut to switch from "fill down" to "copy" with mouse drag RJ Dake Excel Discussion (Misc queries) 3 August 13th 09 05:35 PM
Excel - Golf - how to display "-2" as "2 Under" or "4"as "+4" or "4 Over" in a calculation cell Steve Kay Excel Discussion (Misc queries) 2 August 8th 08 01:54 AM
toggle between autofilter Criteria1:= "*" and "all" Mike Gallagher[_2_] Excel Programming 2 December 26th 07 07:02 PM
Import data "Hangs", A "time out" is needed. Help! :) John37309 Excel Programming 5 July 23rd 07 10:54 AM
Why does excell switch my stock symbol "ACN" to "CAN"? garron Setting up and Configuration of Excel 1 June 21st 07 02:35 AM


All times are GMT +1. The time now is 01:46 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"