ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Pausing a macro (https://www.excelbanter.com/excel-discussion-misc-queries/153714-pausing-macro.html)

Alex.W

Pausing a macro
 
I am trying to develop a macro that deletes a row of data after pausing for
input.

I need a message that asks if they want to delete. If no, quit. If yes,
pause and ask for the cell at the start of the row to be selected.

Once selected, how is the macro re-activated?

If any column other than "A" is selected I need an error message.
If cell "A5" is selected I also need an error message.

I then need the macro to select the 9 cells to the right (in the same row)
of the one selected. This range is then deleted.

Alex.W



Muhammed Rafeek M

Pausing a macro
 
Use the UserForm and RefEdit ****rol

"Alex.W" wrote:

I am trying to develop a macro that deletes a row of data after pausing for
input.

I need a message that asks if they want to delete. If no, quit. If yes,
pause and ask for the cell at the start of the row to be selected.

Once selected, how is the macro re-activated?

If any column other than "A" is selected I need an error message.
If cell "A5" is selected I also need an error message.

I then need the macro to select the 9 cells to the right (in the same row)
of the one selected. This range is then deleted.

Alex.W



JMay

Pausing a macro
 
The below code CLEARS THE CELL CONTENT VERSUS DELETING **Watch out**
Paste this into a standard module:

Sub Foo()
Dim celaddress As String
res = MsgBox("Do you wish to delete a row?", vbYesNo)
If res = vbNo Then Exit Sub
celaddress = Application.InputBox("Enter Cell address of the row to Delete",
Type:=2)
Application.Goto Reference:=Worksheets("Sheet1").Range(celaddress)
If ActiveCell.Column 1 Then
MsgBox "You must select a cell in Column A"
Exit Sub
End If
If ActiveCell.Address = "$A$5" Then
MsgBox "You cannot select cell A5"
Exit Sub
End If
ActiveCell.Offset(0, 1).Resize(1, 9).ClearContents '<< Clears Contents
Versus Deleting !!
End Sub

Write back, if problems encountered..

Jim May


"Alex.W" wrote:

I am trying to develop a macro that deletes a row of data after pausing for
input.

I need a message that asks if they want to delete. If no, quit. If yes,
pause and ask for the cell at the start of the row to be selected.

Once selected, how is the macro re-activated?

If any column other than "A" is selected I need an error message.
If cell "A5" is selected I also need an error message.

I then need the macro to select the 9 cells to the right (in the same row)
of the one selected. This range is then deleted.

Alex.W




All times are GMT +1. The time now is 01:11 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com