Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 94
Default Add Second Page to Code

Good Afternoon All,

I have a macro that excludes a certain page from the Clear code I'm using
below. I now have a second page named "Front Page 2" that I am also looking
to exclude from this function.

After several feeble attempts to modify and add "Front Page 2" to this code,
I've been unsuccessful and was wondering if someone had an idea that would
enable this request.


Thanks so much in advance - Jenny B.


Sub Clear()
For Each Ws In Worksheets
If Ws.Name < "Front Page" Then
Application.ScreenUpdating = False
Ws.Activate
Dim RangeClear As Range
Set RangeClear = Range("a:IV")
RangeClear.ClearContents
Range("A1").Select
ActiveCell.FormulaR1C1 = "0"
Sheets("Front Page").Select
End If
Next
Application.ScreenUpdating = True
End Sub
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 35,218
Default Add Second Page to Code

Option Explicit
Sub Clear()
'Dim RangeClear As Range 'don't need this anymore
Dim ws As Worksheet
For Each ws In Worksheets
Select Case LCase(ws.Name)
Case Is = lcase("front page"), lcase("front page 2")
'skip it
Case Else
ws.Cells.ClearContents
ws.Range("A1").Value = 0 'or "0"?
End Select
Next ws
End Sub

You may decide to avoid all the "front page #" worksheets:

Option Explicit
Sub Clear()
Dim ws As Worksheet
For Each ws In Worksheets
If LCase(Left(ws.Name, 10)) = LCase("front page") Then
'skip it
Else
ws.Cells.ClearContents
ws.Range("A1").Value = 0 'or "0"?
End If
Next ws
End Sub




Jenny B. wrote:

Good Afternoon All,

I have a macro that excludes a certain page from the Clear code I'm using
below. I now have a second page named "Front Page 2" that I am also looking
to exclude from this function.

After several feeble attempts to modify and add "Front Page 2" to this code,
I've been unsuccessful and was wondering if someone had an idea that would
enable this request.

Thanks so much in advance - Jenny B.

Sub Clear()
For Each Ws In Worksheets
If Ws.Name < "Front Page" Then
Application.ScreenUpdating = False
Ws.Activate
Dim RangeClear As Range
Set RangeClear = Range("a:IV")
RangeClear.ClearContents
Range("A1").Select
ActiveCell.FormulaR1C1 = "0"
Sheets("Front Page").Select
End If
Next
Application.ScreenUpdating = True
End Sub


--

Dave Peterson
  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 94
Default Add Second Page to Code

Good Morning,

Thank you Dave. Both are teffific solutions to accomplish the same objective.

Thanks once again for your prompt response and great advice - Jenny B.

"Dave Peterson" wrote:

Option Explicit
Sub Clear()
'Dim RangeClear As Range 'don't need this anymore
Dim ws As Worksheet
For Each ws In Worksheets
Select Case LCase(ws.Name)
Case Is = lcase("front page"), lcase("front page 2")
'skip it
Case Else
ws.Cells.ClearContents
ws.Range("A1").Value = 0 'or "0"?
End Select
Next ws
End Sub

You may decide to avoid all the "front page #" worksheets:

Option Explicit
Sub Clear()
Dim ws As Worksheet
For Each ws In Worksheets
If LCase(Left(ws.Name, 10)) = LCase("front page") Then
'skip it
Else
ws.Cells.ClearContents
ws.Range("A1").Value = 0 'or "0"?
End If
Next ws
End Sub




Jenny B. wrote:

Good Afternoon All,

I have a macro that excludes a certain page from the Clear code I'm using
below. I now have a second page named "Front Page 2" that I am also looking
to exclude from this function.

After several feeble attempts to modify and add "Front Page 2" to this code,
I've been unsuccessful and was wondering if someone had an idea that would
enable this request.

Thanks so much in advance - Jenny B.

Sub Clear()
For Each Ws In Worksheets
If Ws.Name < "Front Page" Then
Application.ScreenUpdating = False
Ws.Activate
Dim RangeClear As Range
Set RangeClear = Range("a:IV")
RangeClear.ClearContents
Range("A1").Select
ActiveCell.FormulaR1C1 = "0"
Sheets("Front Page").Select
End If
Next
Application.ScreenUpdating = True
End Sub


--

Dave Peterson

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
Omit header from first page without embedding header in code ibvalentine Excel Worksheet Functions 6 August 28th 07 05:10 AM
Convert a Number Code to a Text Code Traye Excel Discussion (Misc queries) 3 April 6th 07 09:54 PM
Unprotect Code Module in Code Damien Excel Discussion (Misc queries) 2 April 18th 06 03:10 PM
copying vba code to a standard code module 1vagrowr Excel Discussion (Misc queries) 2 November 23rd 05 04:00 PM
Viewing source code when saved as web page Mark Excel Discussion (Misc queries) 1 March 31st 05 06:26 AM


All times are GMT +1. The time now is 12:56 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"