Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
multiple sheets
Hello,
How do I make the following macro run for all sheets in my workbook? I tried selecting all sheets, but it dosen't work. THanks. Sub frmt() Dim cell As Range Application.ScreenUpdating = False With ActiveSheet.UsedRange ActiveSheet.Name = Range("e61").Value End With With ActiveSheet.UsedRange .Rows.Hidden = False For Each cell In .Columns("h").SpecialCells(xlCellTypeFormulas) If cell.Text = "dlt" Then cell.EntireRow.Hidden = True Next cell End With End Sub |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
multiple sheets
I modified your sub to name each sheet but I has to comment out the second
part - it gave errors. I will leave that part to you Sub frmt() Dim cell As Range Dim ws As Worksheet Application.ScreenUpdating = False For Each ws In Worksheets ws.Name = ws.Range("e61").Value ' With ws.UsedRange ' .Rows.Hidden = False ' For Each cell In .Columns("h").SpecialCells(xlCellTypeFormulas) ' If cell.Text = "dlt" Then cell.EntireRow.Hidden = True ' Next cell ' End With Next ws End Sub best wsihes -- Bernard V Liengme Microsoft Excel MVP www.stfx.ca/people/bliengme remove caps from email "ToddEZ" wrote in message ... Hello, How do I make the following macro run for all sheets in my workbook? I tried selecting all sheets, but it dosen't work. THanks. Sub frmt() Dim cell As Range Application.ScreenUpdating = False With ActiveSheet.UsedRange ActiveSheet.Name = Range("e61").Value End With With ActiveSheet.UsedRange .Rows.Hidden = False For Each cell In .Columns("h").SpecialCells(xlCellTypeFormulas) If cell.Text = "dlt" Then cell.EntireRow.Hidden = True Next cell End With End Sub |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
multiple sheets
give this a try:
Sub frmt() Dim cell As Range Dim ws As Worksheet Application.ScreenUpdating = False For Each ws In ThisWorkbook.Worksheets With ws .Name = .Range("e61").Value With .UsedRange .Rows.Hidden = False On Error Resume Next For Each cell In ..Columns("h").SpecialCells(xlCellTypeFormulas) If cell.Text = "dlt" Then cell.EntireRow.Hidden = True Next On Error GoTo 0 End With End With Next Application.ScreenUpdating = True End Sub -- Gary "ToddEZ" wrote in message ... Hello, How do I make the following macro run for all sheets in my workbook? I tried selecting all sheets, but it dosen't work. THanks. Sub frmt() Dim cell As Range Application.ScreenUpdating = False With ActiveSheet.UsedRange ActiveSheet.Name = Range("e61").Value End With With ActiveSheet.UsedRange .Rows.Hidden = False For Each cell In .Columns("h").SpecialCells(xlCellTypeFormulas) If cell.Text = "dlt" Then cell.EntireRow.Hidden = True Next cell End With End Sub |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
multiple sheets
didn't wrap very well, hopefully this is better. you can indent the lines
manually or with smart indenter. Sub frmt() Dim cell As Range Dim ws As Worksheet Application.ScreenUpdating = False For Each ws In ThisWorkbook.Worksheets With ws .Name = .Range("e61").Value With .UsedRange .Rows.Hidden = False On Error Resume Next For Each cell In .Columns("h").SpecialCells(xlCellTypeFormulas) If cell.Text = "dlt" Then cell.EntireRow.Hidden = True Next On Error GoTo 0 End With End With Next End Sub -- Gary "Gary Keramidas" <GKeramidasATmsn.com wrote in message ... give this a try: Sub frmt() Dim cell As Range Dim ws As Worksheet Application.ScreenUpdating = False For Each ws In ThisWorkbook.Worksheets With ws .Name = .Range("e61").Value With .UsedRange .Rows.Hidden = False On Error Resume Next For Each cell In .Columns("h").SpecialCells(xlCellTypeFormulas) If cell.Text = "dlt" Then cell.EntireRow.Hidden = True Next On Error GoTo 0 End With End With Next Application.ScreenUpdating = True End Sub -- Gary "ToddEZ" wrote in message ... Hello, How do I make the following macro run for all sheets in my workbook? I tried selecting all sheets, but it dosen't work. THanks. Sub frmt() Dim cell As Range Application.ScreenUpdating = False With ActiveSheet.UsedRange ActiveSheet.Name = Range("e61").Value End With With ActiveSheet.UsedRange .Rows.Hidden = False For Each cell In .Columns("h").SpecialCells(xlCellTypeFormulas) If cell.Text = "dlt" Then cell.EntireRow.Hidden = True Next cell End With End Sub |
#5
Posted to microsoft.public.excel.programming
|
|||
|
|||
multiple sheets
Try setting up your code to be more like the following. (This is not
totally tested. There are still some errors in your For loop that I can't debug without knowing your data better. Also, be careful. The SpecialCells property may fail, if there are no formulas!) '---------------------------------------------------------------------- Public Sub FormatAllWorksheets() Dim ws As Worksheet Application.ScreenUpdating = False For Each ws In Worksheets FormatWorksheet ws Next ws End Sub '---------------------------------------------------------------------- Sub FormatWorksheet(ws As Worksheet) Dim cell As Range With ws .Name = .Range("e61").Value End With With ws.UsedRange .Rows.Hidden = False For Each cell In .Columns("h").SpecialCells(xlCellTypeFormulas) If cell.Text = "dlt" Then cell.EntireRow.Hidden = True Next cell End With End Sub -- Regards, Bill Renaud |
#6
Posted to microsoft.public.excel.programming
|
|||
|
|||
multiple sheets
i believe you're seeing the debug error when there are no cells to satisfy the
..SpecialCells(xlCellTypeFormulas) condition. that's why i entered the on error resume next statement in my code. -- Gary "Bill Renaud" wrote in message ... Try setting up your code to be more like the following. (This is not totally tested. There are still some errors in your For loop that I can't debug without knowing your data better. Also, be careful. The SpecialCells property may fail, if there are no formulas!) '---------------------------------------------------------------------- Public Sub FormatAllWorksheets() Dim ws As Worksheet Application.ScreenUpdating = False For Each ws In Worksheets FormatWorksheet ws Next ws End Sub '---------------------------------------------------------------------- Sub FormatWorksheet(ws As Worksheet) Dim cell As Range With ws .Name = .Range("e61").Value End With With ws.UsedRange .Rows.Hidden = False For Each cell In .Columns("h").SpecialCells(xlCellTypeFormulas) If cell.Text = "dlt" Then cell.EntireRow.Hidden = True Next cell End With End Sub -- Regards, Bill Renaud |
#7
Posted to microsoft.public.excel.programming
|
|||
|
|||
multiple sheets
Works GREAT!!!!!!! This saves me so much time! Thanks!!!
"Bill Renaud" wrote: Try setting up your code to be more like the following. (This is not totally tested. There are still some errors in your For loop that I can't debug without knowing your data better. Also, be careful. The SpecialCells property may fail, if there are no formulas!) '---------------------------------------------------------------------- Public Sub FormatAllWorksheets() Dim ws As Worksheet Application.ScreenUpdating = False For Each ws In Worksheets FormatWorksheet ws Next ws End Sub '---------------------------------------------------------------------- Sub FormatWorksheet(ws As Worksheet) Dim cell As Range With ws .Name = .Range("e61").Value End With With ws.UsedRange .Rows.Hidden = False For Each cell In .Columns("h").SpecialCells(xlCellTypeFormulas) If cell.Text = "dlt" Then cell.EntireRow.Hidden = True Next cell End With End Sub -- Regards, Bill Renaud |
#8
Posted to microsoft.public.excel.programming
|
|||
|
|||
multiple sheets
Something to keep in mind: If you have swapped the order of some of
the sheet tabs, and want the order of execution to be the order of the tabs, use: Dim x% for x% = 1 to worksheets.count sheets(x%).Name = sheets(x%).Range("e61").Value next x% Carl. On Nov 10, 4:20 pm, ToddEZ wrote: Works GREAT!!!!!!! This saves me so much time! Thanks!!! "Bill Renaud" wrote: Try setting up your code to be more like the following. (This is not totally tested. There are still some errors in your For loop that I can't debug without knowing your data better. Also, be careful. The SpecialCells property may fail, if there are no formulas!) '---------------------------------------------------------------------- Public Sub FormatAllWorksheets() Dim ws As Worksheet Application.ScreenUpdating = False For Each ws In Worksheets FormatWorksheet ws Next ws End Sub '---------------------------------------------------------------------- Sub FormatWorksheet(ws As Worksheet) Dim cell As Range With ws .Name = .Range("e61").Value End With With ws.UsedRange .Rows.Hidden = False For Each cell In .Columns("h").SpecialCells(xlCellTypeFormulas) If cell.Text = "dlt" Then cell.EntireRow.Hidden = True Next cell End With End Sub -- Regards, Bill Renaud- Hide quoted text - - Show quoted text - |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
How to update data from multiple sheets to one specific sheets | Excel Discussion (Misc queries) | |||
SUMPRODUCT, SUMIF, COUNTIF for multiple sheets for multiple criter | Excel Worksheet Functions | |||
Automated multiple text files into multiple sheets in one workbook | Excel Discussion (Misc queries) | |||
Multiple Sheets (Need to create 500 individual sheets in one workbook, pulling DATA | Excel Worksheet Functions | |||
Changing the value in multiple sheets without selecting those sheets | Excel Programming |