Toggle Button

R

ranswrt

I have 5 togglebutton controls on a worksheet. When they are toggled on a
range of cells are highlighted and unlocked. When they are toggled off the
range of cell are unhighlited and locked is turned on. The problem I have is
the toggle button can be toggled off before the enter key has been pressed
when making changes to the cell. Is there a way to disable the toggle button
when data is started to be typed into a cell until the enter key is pressed
or another cell is selected?
Thanks
 
I

Internetdomainowner

I have 5 togglebutton controls on a worksheet.  When they are toggled on a
range of cells are highlighted and unlocked.  When they are toggled offthe
range of cell are unhighlited and locked is turned on.  The problem I have is
the toggle button can be toggled off before the enter key has been pressed
when making changes to the cell.  Is there a way to disable the toggle button
when data is started to be typed into a cell until the enter key is pressed
or another cell is selected?
Thanks

Right click the sheet you are working in and go to view code... enter
the following...

'=================================================
' The code below will invoke a macro to run when someone clicks a cell
so in this case you can have it disable that toggle button...
'=================================================
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
ToggleButton1.Enabled = False
End Sub

'=================================================
' The code below will invoke a macro after someone finished entering
data into a cell...
'=================================================
Private Sub Worksheet_Calculate()
ToggleButton1.Enabled = True
End Sub


'---------------------------------------- You could also try this
below for a similar effect (not sure what)
Private Sub Worksheet_Change(ByVal Target As Range)

End Sub
 
R

ranswrt

That works except for when there is only cell unlocked on the sheet. Any
ideas on how to get around that?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top