envisioning
New Member
- Joined
- May 2, 2011
- Messages
- 13
Hi guys, I've been working on a VBA code and I need to edit it in a way to delete the row with PAGE in it, as well as the next 8 rows following it.
I have a text file that is being imported and there are over 500 pages, with each page having the same heading, date, etc. etc.. I need to remove the unneccesary rows.
Heres the code so far, and it works like a charm.
==============================
Sub Delete_Rows_with_PAGE()
Dim Firstrow As Long
Dim Lastrow As Long
Dim Lrow As Long
Dim CalcMode As Long
Dim ViewMode As Long
With Application
CalcMode = .Calculation
.Calculation = xlCalculationManual
.ScreenUpdating = False
End With
With ActiveSheet
.Select
ViewMode = ActiveWindow.View
ActiveWindow.View = xlNormalView
.DisplayPageBreaks = False
Firstrow = .UsedRange.Cells(1).Row
Lastrow = .UsedRange.Rows(.UsedRange.Rows.Count).Row
For Lrow = Lastrow To Firstrow Step -1
If Application.CountIf(.Rows(Lrow), "*PAGE*") > 0 _
Then .Rows(Lrow).Delete
Next Lrow
End With
ActiveWindow.View = ViewMode
With Application
.ScreenUpdating = True
.Calculation = CalcMode
End With
End Sub
=================================
I tried fiddling with this for a while, but can not seem to find the right coding to have it erase this row with "PAGE" in it, as well as the next 8 lines.
So if row "A" had "PAGE" in it, I would want this code to remove rows A to I completely.
Thanks in advance!
I have a text file that is being imported and there are over 500 pages, with each page having the same heading, date, etc. etc.. I need to remove the unneccesary rows.
Heres the code so far, and it works like a charm.
==============================
Sub Delete_Rows_with_PAGE()
Dim Firstrow As Long
Dim Lastrow As Long
Dim Lrow As Long
Dim CalcMode As Long
Dim ViewMode As Long
With Application
CalcMode = .Calculation
.Calculation = xlCalculationManual
.ScreenUpdating = False
End With
With ActiveSheet
.Select
ViewMode = ActiveWindow.View
ActiveWindow.View = xlNormalView
.DisplayPageBreaks = False
Firstrow = .UsedRange.Cells(1).Row
Lastrow = .UsedRange.Rows(.UsedRange.Rows.Count).Row
For Lrow = Lastrow To Firstrow Step -1
If Application.CountIf(.Rows(Lrow), "*PAGE*") > 0 _
Then .Rows(Lrow).Delete
Next Lrow
End With
ActiveWindow.View = ViewMode
With Application
.ScreenUpdating = True
.Calculation = CalcMode
End With
End Sub
=================================
I tried fiddling with this for a while, but can not seem to find the right coding to have it erase this row with "PAGE" in it, as well as the next 8 lines.
So if row "A" had "PAGE" in it, I would want this code to remove rows A to I completely.
Thanks in advance!