Activate button when row selected.

J

Johnnyb

I have a button on a protected sheet which will allow the user to delete
a row. The button enabled feature is set to false initially. I would
like to enable the button when the user selects a row or multiple rows.
Then they can delete the selected rows & the sheet will be protected
again.

Any help on this would be greatly appreciated,

Regard's,
Johnnyb
 
S

Sean

Wouldn't this mean that you (Excel) would have to continually check to
see if anything has been selected on the worksheet?
I think it would be easier to always have the button ENABLED, and add
code as part of the deletion routine to check that the user has selected
valid and/or entire rows for deletion.

Sean
"Just press the off switch, and go to sleep!"

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
 
T

Tom Ogilvy

right click on the sheet tab and select view code. Paste in code like
this:

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Target.Address = Target.EntireRow.Address Then
CommandButton1.Enabled = True
Else
CommandButton1.Enabled = False
End If
End Sub
 
J

Johnnyb

Nice one Tom, Thanx

Tom said:
*right click on the sheet tab and select view code. Paste in cod
like
this:

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Target.Address = Target.EntireRow.Address Then
CommandButton1.Enabled = True
Else
CommandButton1.Enabled = False
End If
End Sub
 
Top