Hello. I'm hoping you all can help me create a macro that will loop through multiple sheets to identify errors and log those on an ErrorLog worksheet. The excel file is a system generated report with 115 tabs. Column A = Descriptions and Column B = Values. If Column A is blank " " (there are four spaces and that is it) and Column B has a value, then that row exported in error and needs to be addressed.
I would like for the macro to identify rows where Column A is blank " " and Column B isNumeric and log that Tab Name and Row Number on the Errorlog worksheet.
Any suggestions on how to modify the code below to create the IF And statement that is needed on how to create an output log for the values that are errors?
Thanks in advance for your help.
In the example below row 2 is considered an error.
[TABLE="width: 500"]
[TR]
[TD]Row[/TD]
[TD]Column A[/TD]
[TD]Column B[/TD]
[/TR]
[TR]
[TD]1[/TD]
[TD] Allocation[/TD]
[TD]1[/TD]
[/TR]
[TR]
[TD]2[/TD]
[TD][/TD]
[TD]4[/TD]
[/TR]
[TR]
[TD]3[/TD]
[TD] Benefit[/TD]
[TD]2[/TD]
[/TR]
[/TABLE]
I would like for the macro to identify rows where Column A is blank " " and Column B isNumeric and log that Tab Name and Row Number on the Errorlog worksheet.
Any suggestions on how to modify the code below to create the IF And statement that is needed on how to create an output log for the values that are errors?
Thanks in advance for your help.
Code:
Sub FindErrors()
Dim cell As Range
Dim LastRow As Long
Dim rng As Range
Dim wks As Worksheet
Worksheets.Add(After:=Worksheets(Worksheets.Count)).Name = "ErrorLog"
For Each Sh In Worksheets
Sh.Activate
Set wks = ActiveSheet
Set rng = wks.Range("A10")
LastRow = wks.Cells(Rows.Count, rng.Column).End(xlUp).Row
Set rng = rng.Resize(LastRow - rng.Row + 1, 1)
With Application
.ScreenUpdating = False
.Calculation = xlCalculationManual
For Each cell In rng
' to test for blanks in column A, and if B is a value
If Left(cell, 4) = " " And IsNumeric(##I'm not sure what to put here?) Then
(###Log True values SheetName and Row Number to ErrorLog?)
End If
Next cell
Next Sh
.Calculation = xlCalculationAutomatic
.ScreenUpdating = True
End With
End Sub
In the example below row 2 is considered an error.
[TABLE="width: 500"]
[TR]
[TD]Row[/TD]
[TD]Column A[/TD]
[TD]Column B[/TD]
[/TR]
[TR]
[TD]1[/TD]
[TD] Allocation[/TD]
[TD]1[/TD]
[/TR]
[TR]
[TD]2[/TD]
[TD][/TD]
[TD]4[/TD]
[/TR]
[TR]
[TD]3[/TD]
[TD] Benefit[/TD]
[TD]2[/TD]
[/TR]
[/TABLE]