#1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,501
Default Macro Error

Hi,

Not tested but your short of an 'End if' try this

Sub Macro2()
Sheets("Records").Select
Range("A1:U65536").Select
Selection.Sort Key1:=Range("B2"), Order1:=xlAscending, Key2:=Range("I2") _
, Order2:=xlAscending, Header:=xlGuess, OrderCustom:=1, MatchCase:= _
False, Orientation:=xlTopToBottom, SortMethod:=xlStroke,
DataOption1:= _
xlSortNormal, DataOption2:=xlSortNormal
Selection.AutoFilter Field:=3, Criteria1:="<"

Dim rw As Long
Dim rng As Range
Dim cell As Range

Application.ScreenUpdating = False

Set rng = Sheets("Records").Range("A1:O65536")

With rng.Columns(1)
For Each cell In rng
If Application.WorksheetFunction.CountA(.Parent.Cells (cell.Row,
1).Range("A1:O65536")) = 0 Then
.Parent.Rows(cell.Row).Hidden = True
End If
Next
cell.Parent.PrintOut
.EntireRow.Hidden = False
End With

Application.ScreenUpdating = True

ActiveSheet.ShowAllData
Range("A1:U65536").Sort Key1:=Range("A1"), Order1:=xlAscending, Header:= _
xlGuess, OrderCustom:=1, MatchCase:=False,
Orientation:=xlTopToBottom, _
SortMethod:=xlStroke, DataOption1:=xlSortNormal
End Sub


"Seeker" wrote:

I would like to embed a macro from http://www.rondebruin.nl/print.htm#Print
which would hide empty rows, print and unhide the rows. However, when I run
the macro, it saids "Next without For", so I diable the "Next", then it saids
"End With without With"?

Here is my macro, any suggestion please? Tks

Sub Macro2()
Sheets("Records").Select
Range("A1:U65536").Select
Selection.Sort Key1:=Range("B2"), Order1:=xlAscending, Key2:=Range("I2") _
, Order2:=xlAscending, Header:=xlGuess, OrderCustom:=1, MatchCase:= _
False, Orientation:=xlTopToBottom, SortMethod:=xlStroke,
DataOption1:= _
xlSortNormal, DataOption2:=xlSortNormal
Selection.AutoFilter Field:=3, Criteria1:="<"

Dim rw As Long
Dim rng As Range
Dim cell As Range

Application.ScreenUpdating = False

Set rng = Sheets("Records").Range("A1:O65536")

With rng.Columns(1)
For Each cell In rng
If Application.WorksheetFunction.CountA(.Parent.Cells (cell.Row,
1).Range("A1:O65536")) = 0 Then
.Parent.Rows(cell.Row).Hidden = True
Next
cell.Parent.PrintOut
.EntireRow.Hidden = False
End With

Application.ScreenUpdating = True

ActiveSheet.ShowAllData
Range("A1:U65536").Sort Key1:=Range("A1"), Order1:=xlAscending, Header:= _
xlGuess, OrderCustom:=1, MatchCase:=False,
Orientation:=xlTopToBottom, _
SortMethod:=xlStroke, DataOption1:=xlSortNormal
End Sub

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"