envisioning
New Member
- Joined
- May 2, 2011
- Messages
- 13
Is there a way to make this macro FIND a row with "Page" in it, then check to see if column A (one row above) is NONBLANK?
The code I am using now looks like this:
===================================
</PRE>
Is there any way for there to be a conditional IF in there too? I need it to check to see if there is a NONBLANK cell in column A, one row above the range and one row below the range.
Basically, every time there is data in the A column, it means it is a new CABLE. For the rest of my macros to work, I need each new CABLE to be separated by a blank row.
Every so many lines (in the text report), it inserts a header with a few rows of junk wording (hence the reason behind this macro to erase the 10 rows).
So, is there a way to make this macro FIND a row with "Page" in it, then check to see if column A (one row above) is NONBLANK?
If it is NONBLANK, then I would need it to check 10 rows down to see if Column A is NONBLANK.
If both conditions are TRUE, then ERASE the 10 rows, and insert a blank row.
Otherwise, just erase the 10 rows.
Again the logic:
1) find "PAGE" in a row
2) look one row up in column A to see if it is NONBLANK
3) If false, erase 10 rows
4) If TRUE, then check 10 rows down in column A to see if NONBLANK
5) If TRUE, then erase 10 rows, and insert one blank row
6) If FALSE, then erase 10 rows
Is this possible?
The code I am using now looks like this:
===================================
</PRE>
Code:
Sub Step1_Delete_Text_Data()
Dim CalcMode
Dim LastRow As Range
Dim Row As Range
Dim Rng As Range
Dim Text As String
Dim Wks As Worksheet
Text = "*PAGE*"
Set Wks = ThisWorkbook.Worksheets("Sheet1")
Set Rng = Wks.Range("A1").EntireRow
Set LastRow = Wks.UsedRange.Find("*", , xlValues, xlPart, xlByRows, xlPrevious, False, False)
If LastRow Is Nothing Then Exit Sub
Set Rng = Rng.Resize(RowSize:=LastRow.Row + Rng.Row - 1)
CalcMode = Application.Calculation
Application.Calculation = xlCalculationManual
Application.ScreenUpdating = False
For Each Row In Rng.Rows
If WorksheetFunction.CountIf(Row, Text) Then
Row.Resize(RowSize:=10).EntireRow.Delete
End If
Next Row
Application.Calculation = CalcMode
Application.ScreenUpdating = True
End Sub
Basically, every time there is data in the A column, it means it is a new CABLE. For the rest of my macros to work, I need each new CABLE to be separated by a blank row.
Every so many lines (in the text report), it inserts a header with a few rows of junk wording (hence the reason behind this macro to erase the 10 rows).
So, is there a way to make this macro FIND a row with "Page" in it, then check to see if column A (one row above) is NONBLANK?
If it is NONBLANK, then I would need it to check 10 rows down to see if Column A is NONBLANK.
If both conditions are TRUE, then ERASE the 10 rows, and insert a blank row.
Otherwise, just erase the 10 rows.
Again the logic:
1) find "PAGE" in a row
2) look one row up in column A to see if it is NONBLANK
3) If false, erase 10 rows
4) If TRUE, then check 10 rows down in column A to see if NONBLANK
5) If TRUE, then erase 10 rows, and insert one blank row
6) If FALSE, then erase 10 rows
Is this possible?
Last edited: