OilEconomist
Active Member
- Joined
- Dec 26, 2016
- Messages
- 439
- Office Version
- 2019
- Platform
- Windows
Thanks in advance for any suggestions for which I will give feedback.
The following is code to search for any errors and flag the cell by filling it red and bolding it. How would I then copy the entire row and past it into a sheet titled "Error.Log" when there is or more or errors in that row.
The following is code to search for any errors and flag the cell by filling it red and bolding it. How would I then copy the entire row and past it into a sheet titled "Error.Log" when there is or more or errors in that row.
Code:
Sub ErrorCheck()
'Turn off alerts, screen updates, and automatic calculation
'Turn off Display Alerts
Application.DisplayAlerts = False
'Turn off Screen Update
Application.ScreenUpdating = False
'Turn off Automatic Calculations
Application.Calculation = xlManual
'Dimensioning
Dim LastRow As Long
Dim Error_Row As Long
'Find the last row of data
Sheets("Data").Activate
LastRow = Cells.Find(What:="*", After:=Range("A1"), LookAt:=xlPart, _
LookIn:=xlFormulas, SearchOrder:=xlByRows, _
SearchDirection:=xlPrevious, MatchCase:=False).Row
Error_Row = 3
For i = 3 To LastRow
For j = 1 To 41
If j = 7 Or j = 20 Or j = 21 Or j = 22 Or j = 23 Or j = 31 _
Or j = 32 Or j = 34 Or j = 35 Or j = 36 Or j = 37 _
Or j = 39 Or j = 40 Then
'do nothing
ElseIf Cells(i, j) = "No AFE Xref" And j = 9 Then
Cells(i, j).Font.Bold = True
Cells(i, j).Interior.ColorIndex = 3
ElseIf j = 8 Or j = 9 Or j = 10 Or j = 11 Then
'do nothing
ElseIf Cells(i, j) = "!Xref Error" Or Cells(i, j) = "" Then
Cells(i, j).Font.Bold = True
Cells(i, j).Interior.ColorIndex = 3
End If
Next j
Next i
'Turn on alerts, screen updates, and calculate
'Turn On Display Alerts
Application.DisplayAlerts = True
'Turn on Screen Update
Application.ScreenUpdating = True
'Turn off Automatic Calculations
Calculate
'Place the curser in cell
End Sub