I am using the following code in a workbook, to hide rows, before save, if a value is populated into a specific column. The information on the worksheet in question comes from a separate worksheet. This code works great to hide rows, however, I would like to add code to unhide rows if a value is added/changed in the original worksheet where the info is coming from upon save. Is this possible and how would I go about it?
Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
Dim beginRow As Long, endRow As Long, chkCol As Long, rowCnt As Long
Dim rngResult As Range
Dim ws As Worksheet
beginRow = 3
endRow = 38
chkCol = 14
Set ws = ThisWorkbook.Worksheets("Travel Expense Codes")
For rowCnt = endRow To beginRow Step -1
If Cells(rowCnt, chkCol).Value = "X" Then
ws.Cells(rowCnt, chkCol).EntireRow.Hidden = True
End If
Next rowCnt
End Sub