Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 1
Default macro to ask yes/no question and continue based on answer

I am setting up a macro in excel 2007. Is it possible to get excel to ask me
if I want to delete a specific column with a yes or no selection and have it
delete if I say yes or dont delete if I say no?
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 11,501
Default macro to ask yes/no question and continue based on answer

Try this

Sub askMe()
response = MsgBox("Delete selected column?", vbYesNo)
If response = vbYes Then
If Selection.Columns.Count < 2 Then
Selection.EntireColumn.Delete
Else
MsgBox "More than 1 column selected"
End If
End If
End Sub

Mike

"JasonP CCTM LV" wrote:

I am setting up a macro in excel 2007. Is it possible to get excel to ask me
if I want to delete a specific column with a yes or no selection and have it
delete if I say yes or dont delete if I say no?

  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 36
Default macro to ask yes/no question and continue based on answer

Thanks. Your response, as well as Per Jessen's works perfectly.

"Mike H" wrote:

Try this

Sub askMe()
response = MsgBox("Delete selected column?", vbYesNo)
If response = vbYes Then
If Selection.Columns.Count < 2 Then
Selection.EntireColumn.Delete
Else
MsgBox "More than 1 column selected"
End If
End If
End Sub

Mike

"JasonP CCTM LV" wrote:

I am setting up a macro in excel 2007. Is it possible to get excel to ask me
if I want to delete a specific column with a yes or no selection and have it
delete if I say yes or dont delete if I say no?

  #5   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 1,533
Default macro to ask yes/no question and continue based on answer

Hi

Sub ColToDelete()
TargetCol = "D"
msg = MsgBox("Do you want to delete column " & TargetCol & " ?", vbYesNo)
If msg = vbYes Then Columns(TargetCol).Delete
End Sub

Regards,
Per
"JasonP CCTM LV" <JasonP CCTM skrev i
meddelelsen ...
I am setting up a macro in excel 2007. Is it possible to get excel to ask
me
if I want to delete a specific column with a yes or no selection and have
it
delete if I say yes or dont delete if I say no?




  #6   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 36
Default macro to ask yes/no question and continue based on answer

Thanks. Your solution, like Mike H's, works perfectly.

"Per Jessen" wrote:

Hi

Sub ColToDelete()
TargetCol = "D"
msg = MsgBox("Do you want to delete column " & TargetCol & " ?", vbYesNo)
If msg = vbYes Then Columns(TargetCol).Delete
End Sub

Regards,
Per
"JasonP CCTM LV" <JasonP CCTM skrev i
meddelelsen ...
I am setting up a macro in excel 2007. Is it possible to get excel to ask
me
if I want to delete a specific column with a yes or no selection and have
it
delete if I say yes or dont delete if I say no?



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
can I write an Excel macro to pause for data entry then continue? kiwiwaldo Excel Discussion (Misc queries) 3 June 30th 08 10:25 AM
Excel Macro: Pause & ask user: "Are you sure you want to continue? RoBear! Excel Discussion (Misc queries) 6 March 13th 08 09:14 AM
VB code to continue macro Brian Excel Discussion (Misc queries) 3 May 9th 06 03:12 AM
Can you pause a macro in excel to input data and continue? Hutch Excel Discussion (Misc queries) 1 May 5th 06 06:16 PM
Create a button to continue old macro execution Brian Excel Discussion (Misc queries) 0 May 15th 05 10:22 PM


All times are GMT +1. The time now is 10:04 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"