Activate button when row selected.

  • Thread starter Thread starter Johnnyb
  • Start date Start date
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
 
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!"
 
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
 
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
 

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

Back
Top