View Single Post
  #7   Report Post  
Posted to microsoft.public.excel.programming
Gord Dibben Gord Dibben is offline
external usenet poster
 
Posts: 22,906
Default Clear Contents Macro

Try changing "sheet" to "Sheet"


Gord Dibben MS Excel MVP

On Sat, 21 Jun 2008 10:12:00 -0700, MSE wrote:

Thank you for your input. When I try to run the Macro the screen switches
to visual basic and I get a message that says Run-time error '9' Subscript
out of range, Continue, End, Debug, Help. Any thoughts?

"Don Guillett" wrote:

try this.

Sub clearcellsonsheets()
For i = 1 To 5
ms = "sheet" & i
Sheets(ms).Range("C7,C9,c16:C23,C26:C33").ClearCon tents
Next i
End Sub
--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"MSE" wrote in message
...
I have a workbook with six worksheets. On Sheet 6, I want to create a
macro
linked to an Excel button from the forms toolbar. I want the macro to
only
clear the contents of Sheet 1, Sheet 2, Sheet 3, Sheet 4, and Sheet 5 in
the
following cells C7, C9, C16:C23, and C26:C33. I am trying to write a code
that will do this, any thoughts?