Home |
Search |
Today's Posts |
|
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Looping through Worksheets | Excel Programming | |||
looping through worksheets from addin | Excel Programming | |||
Looping Through Worksheets In A Workbook | Excel Programming | |||
looping through worksheets | Excel Programming | |||
looping through worksheets | Excel Programming |