"Enter" Keystroke within a Macro

norts55

Board Regular
Joined
Jul 27, 2012
Messages
183
I have a simple recorded macro to eliminate some mouse travel and keystrokes when deleting a worksheet named "Proposal Backup".

When I recorded the macro a message box popped up that states "Microsoft Excel will permanently delete this sheet. Do you want to continue?". It has a "Delete" and "Cancel" button with the "Delete" button highlighted.

During the recording process I Hit "Enter" on the Keyboard and this deleted the sheet. The problem I have is, the "Enter" does not get recorded so I have to do this every time I run the macro. Is there a way to make that part of the macro and eliminate having to strike the "Enter" key.


VBA Code:
    ActiveWindow.ScrollWorkbookTabs Sheets:=1
    ActiveWindow.ScrollWorkbookTabs Sheets:=1
    ActiveWindow.ScrollWorkbookTabs Sheets:=1
    Sheets("Proposal Backup").Select
    ActiveWindow.SelectedSheets.Delete
    ActiveWindow.ScrollWorkbookTabs Sheets:=-1
    ActiveWindow.ScrollWorkbookTabs Sheets:=-1
 

Attachments

  • Message_Box.png
    Message_Box.png
    4.4 KB · Views: 4

Excel Facts

Copy a format multiple times
Select a formatted range. Double-click the Format Painter (left side of Home tab). You can paste formatting multiple times. Esc to stop
hi,

You can set DisplayAlerts property to False to suppress prompts and alert messages
while your macro is running when a msgbox would display & pause it awaiting a response.

Application.DisplayAlerts = False

'your code

'return to True
Application.DisplayAlerts = True


Dave
 
Upvote 0
How about
VBA Code:
   Application.DisplayAlerts = False
   Sheets("Proposal Backup").Delete
   Application.DisplayAlerts = True
 
Upvote 0
Glad we could help & thanks for the feedback
 
Upvote 0

Forum statistics

Threads
1,215,743
Messages
6,126,605
Members
449,321
Latest member
syzer

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top