Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10
Default Looping worksheets in workbook

I need help with a macro that will loop through all worksheets in a workbook
and delete the worksheet if the contents in A15 < "C" then re-loop and
delete the "C" in each workbook. Should I create a named range using A15 in
each workbook or just the cell reference as above?

Thank you.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Looping worksheets in workbook


Application.DisplayAlerts = False
For Each sh In Activeworkbook.Worksheets
If sh.Range("A15").Value < "C" Then
sh.Delete
Else
sh.Range("A15").Value = "C"
End If
Next sh

--

HTH

RP
(remove nothere from the email address if mailing direct)


"Wylie C" wrote in message
...
I need help with a macro that will loop through all worksheets in a

workbook
and delete the worksheet if the contents in A15 < "C" then re-loop and
delete the "C" in each workbook. Should I create a named range using A15

in
each workbook or just the cell reference as above?

Thank you.



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,071
Default Looping worksheets in workbook

The code below is untested. Like Bob's it uses a single pass through
the workbook but differs on what it does with non-deleted worksheets.

Option Explicit

Sub testIt()
Dim aWS As Worksheet
For Each aWS In ActiveWorkbook.Worksheets
With aWS.Range("A15")
If .Value < "C" Then
.Parent.Delete
Else
.ClearContents
End If
Next aWS
End Sub

--
Regards,

Tushar Mehta
www.tushar-mehta.com
Excel, PowerPoint, and VBA add-ins, tutorials
Custom MS Office productivity solutions

In article ,
says...
I need help with a macro that will loop through all worksheets in a workbook
and delete the worksheet if the contents in A15 < "C" then re-loop and
delete the "C" in each workbook. Should I create a named range using A15 in
each workbook or just the cell reference as above?

Thank you.

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
Looping through Worksheets Kirk P. Excel Programming 1 February 7th 05 05:14 PM
looping through worksheets from addin jason Excel Programming 1 October 9th 03 01:09 PM
Looping Through Worksheets In A Workbook Steve[_27_] Excel Programming 3 August 5th 03 03:40 PM
looping through worksheets Alex ekster Excel Programming 1 July 21st 03 03:16 AM
looping through worksheets alex Excel Programming 0 July 20th 03 06:43 PM


All times are GMT +1. The time now is 05:27 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"