Hey guys... I'm not really a VB programmer, but I need some help.
Basically, I recorded a macro that deletes a bunch of data in my Excel spreadsheet. I assigned the macro to a button.
I want to have a MsgBox pop up when a user clicks on the button to ask them if they are sure that they want to clear the data. If they click ok, it will continue the deletion. If they click cancel, the macro will end and the data will not be deleted. Cancel should be the default option.
I've tried adding it, but I don't really know the syntax. Here is what I have so far...
Sub Data_Clear()
'
' Data_Clear Macro
' Macro recorded 5/5/2003 by diblesd
'
'
Range("U42:U61"
.Select
Application.CutCopyMode = False
Selection.Copy
Range("C42"
.Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Sheets("Data Import"
.Select
Range("A2:N26"
.Select
Application.CutCopyMode = False
Selection.ClearContents
Range("A28:N53"
.Select
Selection.ClearContents
Range("B55:H200"
.Select
Selection.ClearContents
Range("K55:Q200"
.Select
Selection.ClearContents
Range("A2"
.Select
Sheets("Cal Import"
.Select
Range("A2:N20"
.Select
Selection.ClearContents
Range("A22:N45"
.Select
Selection.ClearContents
Range("Q2:Q21"
.Select
Selection.ClearContents
Range("A2"
.Select
Sheets("Data Entry"
.Select
Range("A2:G2"
.Select
End Sub
Thanks in advance for any help.
Basically, I recorded a macro that deletes a bunch of data in my Excel spreadsheet. I assigned the macro to a button.
I want to have a MsgBox pop up when a user clicks on the button to ask them if they are sure that they want to clear the data. If they click ok, it will continue the deletion. If they click cancel, the macro will end and the data will not be deleted. Cancel should be the default option.
I've tried adding it, but I don't really know the syntax. Here is what I have so far...
Sub Data_Clear()
'
' Data_Clear Macro
' Macro recorded 5/5/2003 by diblesd
'
'
Range("U42:U61"
Application.CutCopyMode = False
Selection.Copy
Range("C42"
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Sheets("Data Import"
Range("A2:N26"
Application.CutCopyMode = False
Selection.ClearContents
Range("A28:N53"
Selection.ClearContents
Range("B55:H200"
Selection.ClearContents
Range("K55:Q200"
Selection.ClearContents
Range("A2"
Sheets("Cal Import"
Range("A2:N20"
Selection.ClearContents
Range("A22:N45"
Selection.ClearContents
Range("Q2:Q21"
Selection.ClearContents
Range("A2"
Sheets("Data Entry"
Range("A2:G2"
End Sub
Thanks in advance for any help.