Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
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? |
#4
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
On Fri, 18 Jul 2008 12:23:01 -0700, JasonP CCTM LV <JasonP CCTM
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? Yes it is. Take a look at the MsgBox Function in the help. Lars-Åke |
#5
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
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 |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
can I write an Excel macro to pause for data entry then continue? | Excel Discussion (Misc queries) | |||
Excel Macro: Pause & ask user: "Are you sure you want to continue? | Excel Discussion (Misc queries) | |||
VB code to continue macro | Excel Discussion (Misc queries) | |||
Can you pause a macro in excel to input data and continue? | Excel Discussion (Misc queries) | |||
Create a button to continue old macro execution | Excel Discussion (Misc queries) |