Hi
Please i need assistance.
I have a vba code that forces a couple of fields to be filled in before saving the workbook which works fine. But the problem now is that as soon as i clear the document to send it out to users to start capturing, it does not allow me to save the document.
Regards and Thanks!
Please i need assistance.
I have a vba code that forces a couple of fields to be filled in before saving the workbook which works fine. But the problem now is that as soon as i clear the document to send it out to users to start capturing, it does not allow me to save the document.
Regards and Thanks!
Code:
Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
Dim rngCell As Range
Dim lngLstRow As Long, lngTCols As Long
Dim lngRowCheck(1 To 9) As String
lngRowCheck(1) = "A"
lngRowCheck(1) = "B"
lngRowCheck(2) = "H"
lngRowCheck(3) = "K"
lngRowCheck(4) = "L"
lngRowCheck(5) = "M"
lngRowCheck(6) = "N"
lngRowCheck(7) = "T"
lngRowCheck(8) = "X"
lngLstRow = ActiveSheet.Range("B" & Rows.Count).End(xlUp).Row
For i = 1 To UBound(lngRowCheck)
For Each rngCell In Range(lngRowCheck(i) & "10:" & lngRowCheck(i) & lngLstRow)
If rngCell.Value = "" Then
MsgBox ("Please enter a mandatory VALUE in cell " & rngCell.Address)
rngCell.Select
Cancel = True
Exit Sub
End If
Next
Next i
End Sub