Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
Hi, i have this macro that cleans sheet2 whenever i run the macro.
It works good but i need that row A and line 1 are not erased. How can i do this? dim resp as long resp = msgbox(Prompt:="Do you want to clean sheet2?",buttons:=vbyesno) if resp = vbyes then worksheets("sheet2").cells.clearcontents end if Thanks |
#2
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
The following macro will do what you want:
================================================== ==== Sub ClearAll() Dim strRange As String Dim r As Range Dim iYesNo As Integer iYesNo = MsgBox("Delete the data in this sheet?", _ vbQuestion + vbYesNo, "Confirm Deletion") If iYesNo = vbNo Then GoTo BailOut strRange = "B2:IV65536" Set r = ActiveWorkbook.ActiveSheet.Range(strRange) r.Clear BailOut: Set r = Nothing Exit Sub End Sub ================================================== ==== -- Kevin Backmann "Micos3" wrote: Hi, i have this macro that cleans sheet2 whenever i run the macro. It works good but i need that row A and line 1 are not erased. How can i do this? dim resp as long resp = msgbox(Prompt:="Do you want to clean sheet2?",buttons:=vbyesno) if resp = vbyes then worksheets("sheet2").cells.clearcontents end if Thanks |
#3
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
Worked just fine, but it clear all the workbook, to clear only sheet2, was
needed to change a little: Set r = Worksheets("Sheet2").Cells.Range(strRange) It makes exactly what i expected! Many Thanks |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Editing a simple macro | Excel Worksheet Functions | |||
Can T Get Macro To Run! | New Users to Excel | |||
Clear Contents Macro | Excel Worksheet Functions | |||
Make Alignment options under format cells available as shortcut | Excel Discussion (Misc queries) | |||
Copy cell format to cell on another worksht and update automatical | Excel Worksheet Functions |