surevyas1984
New Member
- Joined
- Nov 17, 2023
- Messages
- 8
- Office Version
- 365
- Platform
- Windows
Hello Team,
I have created the Macro and I am running multiple macro, if condition is not met then i am getting popup of error message, however i need to create error log sheet where all the errors can be captured in another sheet in case condition is not met. Below is the code for your reference. Appreciate your help
Sub COMBINE()
Call GSTR1
Call GSTR2
Call GSTR3
Call GSTR4
Application.ScreenUpdating = False
' Display a message when the task is completed
MsgBox "Validation done successfully!", vbInformation
End Sub
Sub GSTR1()
Dim lastRow As Long
Dim i As Long
lastRow = Cells(Rows.Count, 9).End(xlUp).Row ' Assuming data starts from row 1
For i = 9 To lastRow
If Not IsEmpty(Range("A" & i).Value) And IsEmpty(Range("BL" & i).Value) Then
MsgBox "Blank cell in column BL at cell BL" & i & ""
End If
Next i
End Sub
Sub GSTR2()
Dim lastRow As Long
Dim i As Long
lastRow = Cells(Rows.Count, 9).End(xlUp).Row ' Assuming data starts from row 1
For i = 9 To lastRow
If (Range("C" & i).Value = "EXWOP" Or Range("C" & i).Value = "EXWP") And Range("AJ" & i).Value = "G" Then
If IsEmpty(Range("AC" & i).Value) Or IsEmpty(Range("AD" & i).Value) Or IsEmpty(Range("AE" & i).Value) Then
MsgBox "Blank cell(s) in columns AC, AD, or AE at row " & i & ""
End If
End If
Next i
End Sub
Sub GSTR3()
Dim lastRow As Long
Dim i As Long
lastRow = Cells(Rows.Count, 9).End(xlUp).Row ' Assuming data starts from row 1
For i = 9 To lastRow
If Not IsEmpty(Range("A" & i).Value) And IsEmpty(Range("BB" & i).Value) Then
MsgBox "Blank cell in column BB at cell BB" & i & ""
End If
Next i
End Sub
Sub GSTR4()
Dim lastRow As Long
Dim i As Long
lastRow = Cells(Rows.Count, 9).End(xlUp).Row ' Assuming data starts from row 1
For i = 9 To lastRow
If Not IsEmpty(Range("A" & i).Value) And IsEmpty(Range("AY" & i).Value) Then
MsgBox "Blank cell in column AY at cell AY" & i & ""
End If
Next i
End Sub
I have created the Macro and I am running multiple macro, if condition is not met then i am getting popup of error message, however i need to create error log sheet where all the errors can be captured in another sheet in case condition is not met. Below is the code for your reference. Appreciate your help
Sub COMBINE()
Call GSTR1
Call GSTR2
Call GSTR3
Call GSTR4
Application.ScreenUpdating = False
' Display a message when the task is completed
MsgBox "Validation done successfully!", vbInformation
End Sub
Sub GSTR1()
Dim lastRow As Long
Dim i As Long
lastRow = Cells(Rows.Count, 9).End(xlUp).Row ' Assuming data starts from row 1
For i = 9 To lastRow
If Not IsEmpty(Range("A" & i).Value) And IsEmpty(Range("BL" & i).Value) Then
MsgBox "Blank cell in column BL at cell BL" & i & ""
End If
Next i
End Sub
Sub GSTR2()
Dim lastRow As Long
Dim i As Long
lastRow = Cells(Rows.Count, 9).End(xlUp).Row ' Assuming data starts from row 1
For i = 9 To lastRow
If (Range("C" & i).Value = "EXWOP" Or Range("C" & i).Value = "EXWP") And Range("AJ" & i).Value = "G" Then
If IsEmpty(Range("AC" & i).Value) Or IsEmpty(Range("AD" & i).Value) Or IsEmpty(Range("AE" & i).Value) Then
MsgBox "Blank cell(s) in columns AC, AD, or AE at row " & i & ""
End If
End If
Next i
End Sub
Sub GSTR3()
Dim lastRow As Long
Dim i As Long
lastRow = Cells(Rows.Count, 9).End(xlUp).Row ' Assuming data starts from row 1
For i = 9 To lastRow
If Not IsEmpty(Range("A" & i).Value) And IsEmpty(Range("BB" & i).Value) Then
MsgBox "Blank cell in column BB at cell BB" & i & ""
End If
Next i
End Sub
Sub GSTR4()
Dim lastRow As Long
Dim i As Long
lastRow = Cells(Rows.Count, 9).End(xlUp).Row ' Assuming data starts from row 1
For i = 9 To lastRow
If Not IsEmpty(Range("A" & i).Value) And IsEmpty(Range("AY" & i).Value) Then
MsgBox "Blank cell in column AY at cell AY" & i & ""
End If
Next i
End Sub