Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Excel / New Users / July 2006

Tip: Looking for answers? Try searching our database.

Repeating instructions in a Macro.

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Art MacNeil - 29 Jul 2006 08:03 GMT
Hello all,

 I have a Macro that clears any data on different 31 tabs and, due to my
lack of knowledge, I do this one tab at a time.  The 31 tabs represent the
maximum possible days in a month. Here's a sample of my Macro:

'======================================================================================================================

'   Clear the data on tab 1.
   Windows("Revenue Tracker.xls").Activate
   Sheets("1").Select
   Range("B4:O126").Select
   Selection.ClearContents
   Range("E4").Select

'----------------------------------------------------------------------------------------------------------------------

'   Clear the data on tab 2.
   Windows("Revenue Tracker.xls").Activate
   Sheets("2").Select
   Range("B4:O126").Select
   Selection.ClearContents
   Range("E4").Select

'----------------------------------------------------------------------------------------------------------------------

I repeat this for every day of the month.

Is there a better way to do this?

Thank you,

Art.
Leo Heuser - 29 Jul 2006 09:38 GMT
> Hello all,
>
[quoted text clipped - 29 lines]
>
> Art.

Hi Art

Here is a shorter version:

Sub ClearTabs()
Dim Counter As Long

   Windows("Revenue Tracker.xls").Activate

   Application.ScreenUpdating = False

   For Counter = 1 To 31
       Sheets(CStr(Counter)).Select
       Range("B4:O126").ClearContents
       Range("E4").Select
   Next Counter

   Application.ScreenUpdating = True

End Sub

Signature

Best regards
Leo Heuser

Followup to newsgroup only please.

Don Guillett - 29 Jul 2006 13:34 GMT
try

for i=1 to sheets.count
sheets(i).Range("B4:O126").ClearContents
next i

Signature

Don Guillett
SalesAid Software
dguillett1@austin.rr.com

> Hello all,
>
[quoted text clipped - 29 lines]
>
> Art.

Rate this thread:






 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.