PDA

View Full Version : excel



oleg_v
01-05-2010, 10:16 PM
hi
i have a macro:

Sub test()
With ActiveSheet
.AutoFilterMode = False
With Range("d1", Range("d" & Rows.Count).End(xlUp))
.AutoFilter 1, "*Record Only*"
On Error Resume Next
.Offset(1).SpecialCells(12).EntireRow.Delete
End With
.AutoFilterMode = False
End With
End Sub

how can i change
"With ActiveSheet" to sheet1


Edit: select your code when posting and hit the vba button to format it for the forum.

thanks

lucas
01-05-2010, 10:25 PM
Untested with your code:

With Sheets("Sheet1")

xld
01-06-2010, 01:18 AM
Qualify the objects as well



Sub test()
With ActiveSheet
.AutoFilterMode = False
With .Range("d1", .Range("d" & .Rows.Count).End(xlUp))
.AutoFilter 1, "*Record Only*"
On Error Resume Next
.Offset(1).SpecialCells(12).EntireRow.Delete
End With
.AutoFilterMode = False
End With
End Sub