Message Box: Delete row x?
i have a macro designed to allow a user to delete a row in a protected
worksheet. In the message box, i'd like to prompt the user as follows: "Are you sure you want to delete row x?" with X being the row number of where the cursor is currently sitting. thanks in advance, tami |
Message Box: Delete row x?
Option Explicit
Sub testme() Dim resp As Long resp = MsgBox(Prompt:="Are you sure you want to delete row " & ActiveCell.Row, _ Buttons:=vbYesNo) If resp = vbYes Then 'unprotect the sheet ActiveCell.EntireRow.Delete 'protect the sheet End If End Sub Tami wrote: i have a macro designed to allow a user to delete a row in a protected worksheet. In the message box, i'd like to prompt the user as follows: "Are you sure you want to delete row x?" with X being the row number of where the cursor is currently sitting. thanks in advance, tami -- Dave Peterson |
Message Box: Delete row x?
perfect!
thanks much! tami "Dave Peterson" wrote: Option Explicit Sub testme() Dim resp As Long resp = MsgBox(Prompt:="Are you sure you want to delete row " & ActiveCell.Row, _ Buttons:=vbYesNo) If resp = vbYes Then 'unprotect the sheet ActiveCell.EntireRow.Delete 'protect the sheet End If End Sub Tami wrote: i have a macro designed to allow a user to delete a row in a protected worksheet. In the message box, i'd like to prompt the user as follows: "Are you sure you want to delete row x?" with X being the row number of where the cursor is currently sitting. thanks in advance, tami -- Dave Peterson |
Message Box: Delete row x?
Hi,
If you protect the sheet in code with a line like ActiveSheet.Protect Password:="x", userinterfaceonly:=True Then there is no need to unprotect and reprotect within the macro. You can run this as a standalone macro or incorporate it into a Workbook_Open routine. -- If this helps, please click the Yes button. Cheers, Shane Devenshire "Tami" wrote: perfect! thanks much! tami "Dave Peterson" wrote: Option Explicit Sub testme() Dim resp As Long resp = MsgBox(Prompt:="Are you sure you want to delete row " & ActiveCell.Row, _ Buttons:=vbYesNo) If resp = vbYes Then 'unprotect the sheet ActiveCell.EntireRow.Delete 'protect the sheet End If End Sub Tami wrote: i have a macro designed to allow a user to delete a row in a protected worksheet. In the message box, i'd like to prompt the user as follows: "Are you sure you want to delete row x?" with X being the row number of where the cursor is currently sitting. thanks in advance, tami -- Dave Peterson |
All times are GMT +1. The time now is 07:31 PM. |
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com