PC Review


Reply
Thread Tools Rate Thread

Add Second Page to Code

 
 
=?Utf-8?B?SmVubnkgQi4=?=
Guest
Posts: n/a
 
      18th Sep 2007
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
 
Reply With Quote
 
 
 
 
Dave Peterson
Guest
Posts: n/a
 
      18th Sep 2007
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 With Quote
 
=?Utf-8?B?SmVubnkgQi4=?=
Guest
Posts: n/a
 
      19th Sep 2007
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 With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
how to display all the code points in a code page ASMO-708 Tony Johansson Microsoft C# .NET 1 3rd Jun 2010 11:39 PM
Master page code executed after child page code Luigi Microsoft ASP .NET 2 22nd May 2006 10:53 AM
After hitting ALT F9 it still prints page code {PAGE} not page num =?Utf-8?B?a25ld3NvbWU=?= Microsoft Word Document Management 2 15th Feb 2006 04:38 PM
WebClient reads html code of the page, but ignores the code of download files. MARTIN LANNY Microsoft VB .NET 1 13th Sep 2005 06:56 AM
Calling code-behind function from in-line code page Fred Armitage Microsoft ASP .NET 2 26th Aug 2003 05:52 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 01:38 AM.