mole999
Well-known Member
- Joined
- Oct 23, 2004
- Messages
- 10,524
- Office Version
- 2019
- 2016
- 2013
- Platform
- Windows
I have something that's driving me bonkers
these two statements exist together, the first runs through no problem at all, the second stalls on the line below, both columns have more than ample values to select from, and I am selecting the whole width of data, and i need to clear the data. The failure is RunTime Error 1004
It's so identical that the working one was pasted over the non working and still fails. must be really simple, please show me what my eyes cannot see
Code:
Sub PrepareData()
Sheets("MasterData").Select
Rows("1:1").Select
Selection.AutoFilter
'** Routines to delete large unecessary portions of file, i.e, wrong area
Selection.AutoFilter Field:=1, Criteria1:="CAC"
Range("A1").Select
AA = Range("a15000").End(xlUp).Row
BB = Range("b15000").End(xlUp).Row
CC = Range("g15000").End(xlUp).Row
DD = Range("l15000").End(xlUp).Row
FF = Application.Max(AA, BB, CC, DD)
zy = "A1:K" & FF
Range(zy).Select
With Sheets("MasterData").Range("A1").CurrentRegion
.Resize(.Rows.Count - 1, .Columns.Count).Offset(1, 0).SpecialCells(xlCellTypeVisible).Clear
End With
Selection.AutoFilter Field:=1
DoEvents 'added following reading to allow time
Selection.AutoFilter Field:=1, Criteria1:="DEC"
Range("A1").Select
AA = Range("a15000").End(xlUp).Row
BB = Range("b15000").End(xlUp).Row
CC = Range("g15000").End(xlUp).Row
DD = Range("l15000").End(xlUp).Row
FF = Application.Max(AA, BB, CC, DD)
zy = "A1:K" & FF
Range(zy).Select
With Sheets("MasterData").Range("A1").CurrentRegion
.Resize(.Rows.Count - 1, .Columns.Count).Offset(1, 0).SpecialCells(xlCellTypeVisible).Clear
End With
Selection.AutoFilter Field:=1
these two statements exist together, the first runs through no problem at all, the second stalls on the line below, both columns have more than ample values to select from, and I am selecting the whole width of data, and i need to clear the data. The failure is RunTime Error 1004
Code:
.Resize(.Rows.Count - 1, .Columns.Count).Offset(1, 0).SpecialCells(xlCellTypeVisible).Clear
It's so identical that the working one was pasted over the non working and still fails. must be really simple, please show me what my eyes cannot see