Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
Micos3
 
Posts: n/a
Default Clear shhet with macro

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   Report Post  
Posted to microsoft.public.excel.misc
Kevin B
 
Posts: n/a
Default Clear shhet with macro

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   Report Post  
Posted to microsoft.public.excel.misc
Micos3
 
Posts: n/a
Default Clear shhet with macro

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
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
Editing a simple macro Connie Martin Excel Worksheet Functions 5 November 29th 05 09:19 PM
Can T Get Macro To Run! Nipper New Users to Excel 2 November 4th 05 04:48 AM
Clear Contents Macro SJC Excel Worksheet Functions 3 October 27th 05 07:26 PM
Make Alignment options under format cells available as shortcut dforrest Excel Discussion (Misc queries) 1 July 14th 05 10:58 PM
Copy cell format to cell on another worksht and update automatical kevinm Excel Worksheet Functions 21 May 19th 05 11:07 AM


All times are GMT +1. The time now is 05:51 PM.

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"