Malicious Office (OLE) / .XLS — malware analysis report

Static analysis result for SHA-256 5ec927a16e6d065c…

MALICIOUS

Office (OLE) / .XLS

2.76 MB Created: 2020-09-16 17:35:23 First seen: 2026-06-27
MD5: 4c1617151aba3de96e139783ffaa82d4 SHA-1: e7a1f6f72e74bd6a653ba8d7d763b3a1422f6a08 SHA-256: 5ec927a16e6d065c5ff599e220a0d9fbb14ebb886ebec95ca393a231990e6eae
310 Risk Score

Heuristics 9

  • VBA macros detected medium 6 related findings OLE_VBA_MACROS
    Document contains VBA macro code
  • Potential Shell call in VBA critical OLE_VBA_SHELL
    Potential Shell call in VBA
    Matched line in script
        hProg = Shell(PathName, WindowState)
  • WScript.Shell usage critical OLE_VBA_WSCRIPT
    WScript.Shell usage
    Matched line in script
        Set myWS = CreateObject("WScript.Shell")
  • CreateObject call high OLE_VBA_CREATEOBJ
    CreateObject call
    Matched line in script
        Set myWS = CreateObject("WScript.Shell")
  • GetObject call high OLE_VBA_GETOBJ
    GetObject call
    Matched line in script
        Set newbook1 = GetObject(FolderName & "\" & fileName)
  • VBA p-code auto-exec with execution tokens high OLE_VBA_PCODE_AUTOEXEC_EXEC
    Triggers on the COMBINATION of two tokens co-occurring in the same compiled VBA/cache stream: an auto-execution entry point (Auto_Open / AutoOpen / Document_Open / Workbook_Open / Auto_Close / AutoClose) AND a shell/download/object-execution token (Shell, CreateObject, GetObject, PowerShell, cmd.exe, URLDownloadToFile, WinHttp, XMLHTTP, ADODB.Stream, ShellExecute, ExecuteExcel4Macro). Neither token alone fires it — it is the pairing that flags p-code-only or source-extraction-failure macro documents where the visible VBA source is unavailable. The matched tokens are named in the detail line below.
  • Workbook_Open macro low OLE_VBA_WBOPEN
    Workbook_Open macro
    Matched line in script
    Private Sub Workbook_Open()
  • Reference to Windows Script Host high SC_STR_WSCRIPT
    Reference to Windows Script Host
  • Embedded URL info EMBEDDED_URL
    One or more URLs were extracted from the document. The URL itself is not a detection — see the per-URL labels for which channel (macro, JS, link annotation, document body, ...) reached each URL.
    URL http://www.frez.co.uk In document text (OLE body)

Extracted artifacts 1

Files carved from inside the sample during analysis.

FilenameKindSourceSize
macros.bas vba-macro oletools.olevba.extract_macros (decoded VBA source) 2248931 bytes
SHA-256: f5b1069a4370a747c568b767cbc6cb2ed20c10c416f710e115efc77476a7e98a
Preview script
First 1,000 lines of the extracted script
Attribute VB_Name = "ThisWorkbook"
Attribute VB_Base = "0{00020819-0000-0000-C000-000000000046}"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = True
Attribute VB_TemplateDerived = False
Attribute VB_Customizable = True

Option Explicit
Private Sub Workbook_Open()

    Dim ActiveWorkbook As Workbook
    Set ActiveWorkbook = ThisWorkbook
    Application.ScreenUpdating = False
    Application.EnableEvents = False

    Application.Calculation = xlManual
    ActiveWorkbook.Unprotect (Pwd)
    MakeSheetsVisible
    '***********************************************************
  '                       AMENDMENT CODE
'     ***********************************************************
    Dim WS As Worksheet
    'Call function for amendment
    On Error Resume Next
    Set WS = Worksheets("Amendment")
    On Error GoTo 0
    If Not WS Is Nothing Then
       If WS.Cells(1, 1).value <> "" Or WS.Cells(2, 1).value <> "" Then
            'unlock Spouse Fields initially
            Worksheets("A_Basic_Info").toggleBusinessTypeComp (False)
            Worksheets("A_Basic_Info").toggleEPZCompany (False)
            Worksheets("A_Basic_Info").toggleNewList (False)
            Worksheets("A_Basic_Info").toggleKenyaACT (False)
            Worksheets("A_Basic_Info").toggleTaxComputation (False)
            Worksheets("A_Basic_Info").toggleEState (True)
    
            Call fillDataInFields("Amendment")
          
          ' changes done for extractive industries ----start
           Dim rangeName As String
           Dim startRow As String
           Dim endRow As String
           Dim p As Integer
           rangeName = Worksheets("E1_IDA_CA").Range("DeprIntengAst.List").Address
           startRow = Worksheets("E1_IDA_CA").Range(rangeName).row
           endRow = Worksheets("E1_IDA_CA").Range(rangeName).Rows.count + startRow - 1
           Dim year As Integer
           Dim date1 As String
           Dim str As String
           Dim strArr As Variant
           Dim count As Integer
           Dim endDate As String
           Dim startDt As Variant
           
          For p = startRow To endRow
            'date1 = Worksheets("E1_IDA_CA").Range("M" & p & ":M" & p).value
            'strArr = Split(date1, GetLocalInfo(29))
            'year = Int(strArr(2))
            
                endDate = Worksheets("E1_IDA_CA").Range("M" & p & ":M" & p).value
            If endDate <> "" Then
                startDt = Split(endDate, GetLocalInfo(29))
                year = Int(startDt(2))
                Worksheets("E1_IDA_CA").Range("E" & p & ":E" & p).value = year
           End If
          Next
          If (Worksheets("A_Basic_Info").Range("RetInf.YearIncome").value < 2015) Then
                Call lockUnlock_cell_rng_without_clearing_contents("K_Previous_Years_Losses", "C4:G8", True)
            Else
                  Call lockUnlock_cell_rng_without_clearing_contents("K_Previous_Years_Losses", "C4:G8", False)
            End If
           If Worksheets("A_Basic_Info").Range("RetInf.DTAACredits").value = "Yes" Then
                        ActiveWorkbook.Unprotect (Pwd)
                        Worksheets("J_DTAA_Credits").Unprotect (Pwd)
                        Worksheets("J_DTAA_Credits").Visible = xlSheetVisible
                            Call lockUnlock_cell_rng_without_clearing_contents("J_DTAA_Credits", "DTAACredits.Details", False, "6")
                        Worksheets("J_DTAA_Credits").Protect (Pwd)
                        
                    ElseIf Worksheets("A_Basic_Info").Range("RetInf.DTAACredits").value = "No" Then
                    ActiveWorkbook.Unprotect (Pwd)
                        Worksheets("J_DTAA_Credits").Unprotect (Pwd)
                        Worksheets("J_DTAA_Credits").Visible = xlSheetHidden
                
                         Call lockUnlock_cell_rng("J_DTAA_Credits", "DTAACredits.Details", True, "6")
                           Worksheets("J_DTAA_Credits").Protect (Pwd)
                    End If
          If Worksheets("M_Tax_Computation").Range("TaxComp.NonDTAACountryCreditsHidden").value = "" Then
            Worksheets("M_Tax_Computation").Range("TaxComp.NonDTAACountryCreditsHidden").value = 0#
          End If
          If Worksheets("A_Basic_Info").Range("RetInf.IsExtIndTyp").value <> "" Then
           If Worksheets("A_Basic_Info").Range("RetInf.IsExtIndTyp").value = "MINING" Or Worksheets("A_Basic_Info").Range("RetInf.IsExtIndTyp").value = "OIL/GAS" Then
             Worksheets("A_Basic_Info").Range("RetInf.IsExtInd").value = "Yes"
            Worksheets("B1_Profit_Loss_Account_Ext_Ind").Visible = xlSheetVisible
            Call lockUnlock_cell_rng_without_clearing_contents("A_Basic_Info", "RetInf.IsExtIndTyp", False)
            
             Call lockUnlock_cell_rng_without_clearing_contents("B_Profit_Loss_Account", "C4:C5", True)
             Call lockUnlock_cell_rng_without_clearing_contents("B_Profit_Loss_Account", "C9:C11", True)
             Call lockUnlock_cell_rng_without_clearing_contents("B_Profit_Loss_Account", "C14:C15", True)
             Call lockUnlock_cell_rng_without_clearing_contents("B_Profit_Loss_Account", "C18:C19", True)
             Call lockUnlock_cell_rng_without_clearing_contents("B_Profit_Loss_Account", "C22:C27", True)
             Call lockUnlock_cell_rng_without_clearing_contents("B_Profit_Loss_Account", "C30:C32", True)
             Call lockUnlock_cell_rng_without_clearing_contents("B_Profit_Loss_Account", "C37:C46", True)
             Call lockUnlock_cell_rng_without_clearing_contents("B_Profit_Loss_Account", "C50:C76", True)
             Call lockUnlock_cell_rng_without_clearing_contents("B_Profit_Loss_Account", "C80:C83", True)
             Call lockUnlock_cell_rng_without_clearing_contents("B_Profit_Loss_Account", "C86:C94", True)
             Call lockUnlock_cell_rng_without_clearing_contents("B_Profit_Loss_Account", "C97:C102", True)
             Call lockUnlock_cell_rng_without_clearing_contents("B_Profit_Loss_Account", "C115:C119", True)
             Call lockUnlock_cell_rng_without_clearing_contents("B_Profit_Loss_Account", "C124:C128", True)
             'lockCell = False
             
             Else
             Worksheets("A_Basic_Info").Range("RetInf.IsExtInd").value = "No"
             Call lockUnlock_cell_rng("A_Basic_Info", "RetInf.IsExtIndTyp", True)
             
            End If
            
        End If
          
          ' changes done for extractive industries ----end
                         
            Call lockUnlock_cell_rng_without_clearing_contents("G_WHT_Credits", "A3:A4", True)
            Call lockUnlock_cell_rng_without_clearing_contents("G_WHT_Credits", "B3:B4", True)
            Call lockUnlock_cell_rng_without_clearing_contents("G_WHT_Credits", "C3:C4", True)
            Call lockUnlock_cell_rng_without_clearing_contents("G_WHT_Credits", "D3:D4", True)
            Call lockUnlock_cell_rng_without_clearing_contents("G_WHT_Credits", "E3:E4", True)
            Call lockUnlock_cell_rng_without_clearing_contents("H_Advance_Tax_Credits", "A3:A4", True)
            Call lockUnlock_cell_rng_without_clearing_contents("H_Advance_Tax_Credits", "B3:B4", True)
            Call lockUnlock_cell_rng_without_clearing_contents("H_Advance_Tax_Credits", "C3:C4", True)
            Call lockUnlock_cell_rng_without_clearing_contents("H_Advance_Tax_Credits", "D3:D4", True)
            Call lockUnlock_cell_rng_without_clearing_contents("H_Advance_Tax_Credits", "E3:E4", True)
            Call lockUnlock_cell_rng_without_clearing_contents("H_Advance_Tax_Credits", "F3:F4", True)
            Call lockUnlock_cell_rng_without_clearing_contents("M_Tax_Computation", "TaxComp.WithHoldingListTO", False)
            Call lockUnlock_cell_rng_without_clearing_contents("M_Tax_Computation", "TaxComp.VehicleAdvTaxPaidListTO", False)
            Worksheets("Amendment").Visible = xlSheetHidden

            If Worksheets("A_Basic_Info").Range("RetInf.DeclarePreferentialCerti").value = "Yes" Then
                 Call togglePrefCells("Yes")
            End If
            If Worksheets("A_Basic_Info").Range("RetInf.BussTypeCode").value = "COMP" And Worksheets("A_Basic_Info").Range("RetInf.BussSubTypeCode").value = "PUBCOMP" Or Worksheets("A_Basic_Info").Range("RetInf.BussSubTypeCode").value = "PVTCOMP" Or Worksheets("A_Basic_Info").Range("RetInf.BussSubTypeCode").value = "FRGNCOMP" Then
                'Worksheets("A_Basic_Info").toggleBusinessTypeCompPub (False)
                Worksheets("A_Basic_Info").toggleEPZCompany (True)
            End If
            If Worksheets("A_Basic_Info").Range("RetInf.BussTypeCode").value = "COMP" And Worksheets("A_Basic_Info").Range("RetInf.BussSubTypeCode").value = "PVTCOMP" Or Worksheets("A_Basic_Info").Range("RetInf.BussSubTypeCode").value = "FRGNCOMP" Then
                Worksheets("A_Basic_Info").toggleBusinessType (True)
            End If
             If Worksheets("A_Basic_Info").Range("RetInf.BussTypeCode").value = "COMP" And Worksheets("A_Basic_Info").Range("RetInf.BussSubTypeCode").value = "EPZCOMP" Then
                'Worksheets("A_Basic_Info").toggleEPZCompany (False)
                Worksheets("A_Basic_Info").toggleNewList (True)
            End If

            If Worksheets("A_Basic_Info").Range("RetInf.BussTypeCode").value = "NGO" Or Worksheets("A_Basic_Info").Range("RetInf.BussTypeCode").value = "INTERORG" Or Worksheets("A_Basic_Info").Range("RetInf.BussTypeCode").value = "DEPLOORG" Then
                Worksheets("A_Basic_Info").toggleBusinessTypeComp (True)
            End If
            If Worksheets("A_Basic_Info").Range("RetInf.BussTypeCode").value = "GOVINS" Or Worksheets("A_Basic_Info").Range("RetInf.BussTypeCode").value = "OTHERS" Then
                'Worksheets("A_Basic_Info").toggleBusinessSubTypeGovtOth (False)
                Worksheets("A_Basic_Info").toggleBusinessTypeGovtOth (True)
            End If

            If Worksheets("A_Basic_Info").Range("RetInf.BussTypeCode").value = "GOVINS" Then
                If (Worksheets("A_Basic_Info").Range("RetInf.BussSubTypeCode").value = "MINISTRY" Or Worksheets("A_Basic_Info").Range("RetInf.BussSubTypeCode").value = "PARASCOM" Or Worksheets("A_Basic_Info").Range("RetInf.BussSubTypeCode").value = "LOCAUTH") Then
                    Worksheets("A_Basic_Info").toggleEPZandLSTCompany (True)
                End If
            End If

            If Worksheets("A_Basic_Info").Range("RetInf.BussTypeCode").value = "OTHERS" Then
                If (Worksheets("A_Basic_Info").Range("RetInf.BussSubTypeCode").value = "CLSOCASS" _
                Or Worksheets("A_Basic_Info").Range("RetInf.BussSubTypeCode").value = "ESTTRST" _
                Or Worksheets("A_Basic_Info").Range("RetInf.BussSubTypeCode").value = "ESTAT" _
                Or Worksheets("A_Basic_Info").Range("RetInf.BussSubTypeCode").value = "GOVTSCHL" _
                Or Worksheets("A_Basic_Info").Range("RetInf.BussSubTypeCode").value = "PVTTRST" _
                Or Worksheets("A_Basic_Info").Range("RetInf.BussSubTypeCode").value = "CORPTRST" _
                Or Worksheets("A_Basic_Info").Range("RetInf.BussSubTypeCode").value = "FMTRST" _
                Or Worksheets("A_Basic_Info").Range("RetInf.BussSubTypeCode").value = "PLTCPTY" _
                Or Worksheets("A_Basic_Info").Range("RetInf.BussSubTypeCode").value = "TRDUNION") Then
                    Worksheets("A_Basic_Info").toggleEPZandLSTCompany (True)
                End If
            End If

            If Worksheets("A_Basic_Info").Range("RetInf.BussTypeCode").value = "COMP" And Worksheets("A_Basic_Info").Range("RetInf.BussSubTypeCode").value = "FRGNCOMP" Then
                Worksheets("A_Basic_Info").toggleTaxComputation (True)
            End If

            If Worksheets("A_Basic_Info").Range("RetInf.BussTypeCode").value = "OTHERS" Then
                If (Worksheets("A_Basic_Info").Range("RetInf.BussSubTypeCode").value = "ESTTRST" _
                Or Worksheets("A_Basic_Info").Range("RetInf.BussSubTypeCode").value = "ESTAT") Then
                    'Worksheets("A_Basic_Info").toggleEState (False)
                End If
            End If

            If Worksheets("A_Basic_Info").Range("RetInf.KenyaOutsideYN").value = "No" Then
                Worksheets("A_Basic_Info").toggleKenyaACT (True)
            End If

            'new code added for Bank Section Enable/Disable Start
'            If Worksheets("A_Basic_Info").Range("BankName").value <> "" Then
'                Call lockUnlock_cell_rng_without_clearing_contents("A_Basic_Info", "BankName", False)
'                Call lockUnlock_cell_rng_without_clearing_contents("A_Basic_Info", "BankBranchName", False)
'                Call lockUnlock_cell_rng_without_clearing_contents("A_Basic_Info", "BankDtl.City", False)
'                Call lockUnlock_cell_rng_without_clearing_contents("A_Basic_Info", "BankDtl.AccName", False)
'                Call lockUnlock_cell_rng_without_clearing_contents("A_Basic_Info", "BankDtl.AccNumber", False)
'            Else
'                Call lockUnlock_cell_rng_without_clearing_contents("A_Basic_Info", "BankName", True)
'                Call lockUnlock_cell_rng_without_clearing_contents("A_Basic_Info", "BankBranchName", True)
'                Call lockUnlock_cell_rng_without_clearing_contents("A_Basic_Info", "BankDtl.City", True)
'                Call lockUnlock_cell_rng_without_clearing_contents("A_Basic_Info", "BankDtl.AccName", True)
'                Call lockUnlock_cell_rng_without_clearing_contents("A_Basic_Info", "BankDtl.AccNumber", True)
'            End If
            'new code added for Bank Section Enable/Disable End
        End If
    End If

  
'***********************************************************
        MsgBox "Please DO NOT Cut and Paste any values in the workbook."

        Worksheets("Sheet1").Unprotect (Pwd)
        Worksheets("Sheet1").Range("A1:Z3").ClearContents

        Worksheets("Data").Visible = xlHidden
        Worksheets("Errors").Unprotect (Pwd)
        Worksheets("Errors").Range("A2:E65535").ClearContents
        Worksheets("Errors").Protect (Pwd)
        
        Dim i As Integer
        For i = 1 To Worksheets.count
          Worksheets(i).Protect (Pwd)
        Next

        '*************************use this code in case if tooltip message updation is required********************
        '***************************start********************
        'Dim sheetNumber As Integer
        'Dim rowNumber As Integer
        'Dim colNumber As Integer
        'Dim searchString, replaceString, Str As String
        'searchString = "Special characters like Space , - . / # : are allowed."
        'replaceString = "Special characters like Space , - . / : are allowed."
        'For sheetNumber = 1 To Worksheets.Count
        '    Worksheets(sheetNumber).Unprotect (Pwd)
        '    On Error Resume Next
        '    For rowNumber = 1 To 500
        '        For colNumber = 1 To 40
        ''            If UCase(Trim(Worksheets(sheetNumber).Cells(rowNumber, colNumber).Validation.InputTitle)) = "DATE" Or UCase(Trim(Worksheets(sheetNumber).Cells(rowNumber, colNumber).Validation.InputTitle)) = "DATE:" Then
        '             If Worksheets(sheetNumber).Cells(rowNumber, colNumber).Validation.InputMessage <> "" Then
        '                If InStr(1, Worksheets(sheetNumber).Cells(rowNumber, colNumber).Validation.InputMessage, searchString) <> 0 Then
        '                     Str = Replace(Worksheets(sheetNumber).Cells(rowNumber, colNumber).Validation.InputMessage, searchString, replaceString)
        '                     Worksheets(sheetNumber).Cells(rowNumber, colNumber).Validation.InputMessage = Str
        '                End If
        ''                Worksheets(sheetNumber).Cells(rowNumber, colNumber).Validation.InputTitle = "Date:"
        ''                Worksheets(sheetNumber).Cells(rowNumber, colNumber).Validation.InputMessage = "Enter date value in dd/mm/yyyy format."
        ''                Worksheets(sheetNumber).Cells(rowNumber, colNumber).Validation.ErrorMessage = "Please enter date value in dd/mm/yyyy format."
        '             End If
        ''            End If
        '        Next
        '    Next
        '    Worksheets(sheetNumber).Protect (Pwd)
        'Next
        '***************************end***********************
        Worksheets("Validations").Calculate
        Worksheets("ValidationList").Calculate
        Call resetRtnYrComboBox("Data", "D")
        
        'With ActiveWorkbook
       '     .Worksheets("A_Basic_Info").Visible = xlSheetVisible
        '    .Worksheets("A_Basic_Info").Activate
       ' End With
       
        ActiveWorkbook.Protect (Pwd)
        'Worksheets("A_Basic_Info").Cells(3, 2).Select
        Application.ScreenUpdating = True
        Application.EnableEvents = True
        Application.CalculateFull
        Application.Calculation = xlCalculationAutomatic
End Sub
'*** In the ThisWorkbook Module ***


Private Sub Workbook_Activate()
    Call ToggleCutCopyAndPaste(False)
    
    Worksheets("A_Basic_Info").Activate
End Sub

Private Sub Workbook_BeforeClose(Cancel As Boolean)
   Call ToggleCutCopyAndPaste(True)
    If Not isHideUnhidePerformed Then
        Call MacrosDisClose
    End If
End Sub

Private Sub Workbook_SheetSelectionChange(ByVal Sh As Object, ByVal Target As Range)
    Call ToggleCutCopyAndPaste(False)
End Sub

' added by mitali to handle formula generation issue while negative value is entered
Private Sub Workbook_SheetBeforeDoubleClick(ByVal Sh As Object, ByVal Target As Range, Cancel As Boolean)
    Cancel = True
    MsgBox "Double clicking any where is not allowed in the workbook"
End Sub

Private Sub Workbook_SheetBeforeRightClick(ByVal Sh As Object, ByVal Target As Range, Cancel As Boolean)
    Cancel = True
    MsgBox "Right Click has been disabled for this workbook."
End Sub

'Added by Atul : Start
Private Sub Workbook_AfterSave(ByVal Success As Boolean)
    If isCalledOnClose And Success Then
        ThisWorkbook.Saved = False
        Call HideAllSheets
        isCalledOnClose = False
        ThisWorkbook.Saved = True
        ThisWorkbook.Save
'        Application.EnableEvents = False
'        ThisWorkbook.Close SaveChanges:=True
    End If
End Sub
'Added by Atul : End


Private Sub Workbook_SheetActivate(ByVal Sh As Object)

If Sh.name = "B_Profit_Loss_Account" Then
    'MsgBox "hi Ali"
    Worksheets("B_Profit_Loss_Account").Activate
    Worksheets("B_Profit_Loss_Account").Unprotect (Pwd)
    
    Dim rangeName As String
     Dim startRow As String
     Dim endRow As String
     Dim i As Integer
    If (Worksheets("A_Basic_Info").Range("RetInf.IsExtInd").value = "Yes") Then
         For i = 4 To 5
            Worksheets("B_Profit_Loss_Account").Range("C" & i & ":C" & i).value = Worksheets("B1_Profit_Loss_Account_Ext_Ind").Range("R" & i & ":R" & i).value
         Next
         For i = 9 To 11
            Worksheets("B_Profit_Loss_Account").Range("C" & i & ":C" & i).value = Worksheets("B1_Profit_Loss_Account_Ext_Ind").Range("R" & i & ":R" & i).value
         Next
         For i = 14 To 15
            Worksheets("B_Profit_Loss_Account").Range("C" & i & ":C" & i).value = Worksheets("B1_Profit_Loss_Account_Ext_Ind").Range("R" & i & ":R" & i).value
         Next
         For i = 18 To 19
            Worksheets("B_Profit_Loss_Account").Range("C" & i & ":C" & i).value = Worksheets("B1_Profit_Loss_Account_Ext_Ind").Range("R" & i & ":R" & i).value
         Next
         For i = 22 To 27
            Worksheets("B_Profit_Loss_Account").Range("C" & i & ":C" & i).value = Worksheets("B1_Profit_Loss_Account_Ext_Ind").Range("R" & i & ":R" & i).value
         Next
         For i = 30 To 32
            Worksheets("B_Profit_Loss_Account").Range("C" & i & ":C" & i).value = Worksheets("B1_Profit_Loss_Account_Ext_Ind").Range("R" & i & ":R" & i).value
         Next
         For i = 37 To 47
            Worksheets("B_Profit_Loss_Account").Range("C" & i & ":C" & i).value = Worksheets("B1_Profit_Loss_Account_Ext_Ind").Range("R" & i & ":R" & i).value
         Next
         For i = 50 To 76
            Worksheets("B_Profit_Loss_Account").Range("C" & i & ":C" & i).value = Worksheets("B1_Profit_Loss_Account_Ext_Ind").Range("R" & i & ":R" & i).value
         Next
         For i = 80 To 83
            Worksheets("B_Profit_Loss_Account").Range("C" & i & ":C" & i).value = Worksheets("B1_Profit_Loss_Account_Ext_Ind").Range("R" & i & ":R" & i).value
         Next
         For i = 86 To 94
            Worksheets("B_Profit_Loss_Account").Range("C" & i & ":C" & i).value = Worksheets("B1_Profit_Loss_Account_Ext_Ind").Range("R" & i & ":R" & i).value
         Next
         For i = 97 To 102
            Worksheets("B_Profit_Loss_Account").Range("C" & i & ":C" & i).value = Worksheets("B1_Profit_Loss_Account_Ext_Ind").Range("R" & i & ":R" & i).value
         Next
         For i = 104 To 104
            Worksheets("B_Profit_Loss_Account").Range("C" & i & ":C" & i).value = Worksheets("B1_Profit_Loss_Account_Ext_Ind").Range("R" & i & ":R" & i).value
         Next
    End If
End If
Worksheets("B_Profit_Loss_Account").Protect (Pwd)


'changes for M sheet --start
  If Sh.name = "M_Tax_Computation" Then
  
    'Worksheets("B_Profit_Loss_Account").Activate
    Worksheets("B_Profit_Loss_Account").Unprotect (Pwd)
    
    If (Worksheets("A_Basic_Info").Range("RetInf.IsExtInd").value = "Yes") Then
      For i = 4 To 5
            Worksheets("B_Profit_Loss_Account").Range("C" & i & ":C" & i).value = Worksheets("B1_Profit_Loss_Account_Ext_Ind").Range("R" & i & ":R" & i).value
         Next
         For i = 9 To 11
            Worksheets("B_Profit_Loss_Account").Range("C" & i & ":C" & i).value = Worksheets("B1_Profit_Loss_Account_Ext_Ind").Range("R" & i & ":R" & i).value
         Next
         For i = 14 To 15
            Worksheets("B_Profit_Loss_Account").Range("C" & i & ":C" & i).value = Worksheets("B1_Profit_Loss_Account_Ext_Ind").Range("R" & i & ":R" & i).value
         Next
         For i = 18 To 19
            Worksheets("B_Profit_Loss_Account").Range("C" & i & ":C" & i).value = Worksheets("B1_Profit_Loss_Account_Ext_Ind").Range("R" & i & ":R" & i).value
         Next
         For i = 22 To 27
            Worksheets("B_Profit_Loss_Account").Range("C" & i & ":C" & i).value = Worksheets("B1_Profit_Loss_Account_Ext_Ind").Range("R" & i & ":R" & i).value
         Next
         For i = 30 To 32
            Worksheets("B_Profit_Loss_Account").Range("C" & i & ":C" & i).value = Worksheets("B1_Profit_Loss_Account_Ext_Ind").Range("R" & i & ":R" & i).value
         Next
         For i = 37 To 47
            Worksheets("B_Profit_Loss_Account").Range("C" & i & ":C" & i).value = Worksheets("B1_Profit_Loss_Account_Ext_Ind").Range("R" & i & ":R" & i).value
         Next
         For i = 50 To 76
            Worksheets("B_Profit_Loss_Account").Range("C" & i & ":C" & i).value = Worksheets("B1_Profit_Loss_Account_Ext_Ind").Range("R" & i & ":R" & i).value
         Next
         For i = 80 To 83
            Worksheets("B_Profit_Loss_Account").Range("C" & i & ":C" & i).value = Worksheets("B1_Profit_Loss_Account_Ext_Ind").Range("R" & i & ":R" & i).value
         Next
         For i = 86 To 94
            Worksheets("B_Profit_Loss_Account").Range("C" & i & ":C" & i).value = Worksheets("B1_Profit_Loss_Account_Ext_Ind").Range("R" & i & ":R" & i).value
         Next
         For i = 97 To 102
            Worksheets("B_Profit_Loss_Account").Range("C" & i & ":C" & i).value = Worksheets("B1_Profit_Loss_Account_Ext_Ind").Range("R" & i & ":R" & i).value
         Next
         For i = 104 To 104
            Worksheets("B_Profit_Loss_Account").Range("C" & i & ":C" & i).value = Worksheets("B1_Profit_Loss_Account_Ext_Ind").Range("R" & i & ":R" & i).value
         Next
    
    End If
    
  End If
'changes for M sheet --end
'changes for N sheet -- start
If Sh.name = "N_Estate_Trust_Distri_Inco" Then
  
    'Worksheets("B_Profit_Loss_Account").Activate
    Worksheets("B_Profit_Loss_Account").Unprotect (Pwd)
    
    If (Worksheets("A_Basic_Info").Range("RetInf.IsExtInd").value = "Yes") Then
      For i = 4 To 5
            Worksheets("B_Profit_Loss_Account").Range("C" & i & ":C" & i).value = Worksheets("B1_Profit_Loss_Account_Ext_Ind").Range("R" & i & ":R" & i).value
         Next
         For i = 9 To 11
            Worksheets("B_Profit_Loss_Account").Range("C" & i & ":C" & i).value = Worksheets("B1_Profit_Loss_Account_Ext_Ind").Range("R" & i & ":R" & i).value
         Next
         For i = 14 To 15
            Worksheets("B_Profit_Loss_Account").Range("C" & i & ":C" & i).value = Worksheets("B1_Profit_Loss_Account_Ext_Ind").Range("R" & i & ":R" & i).value
         Next
         For i = 18 To 19
            Worksheets("B_Profit_Loss_Account").Range("C" & i & ":C" & i).value = Worksheets("B1_Profit_Loss_Account_Ext_Ind").Range("R" & i & ":R" & i).value
         Next
         For i = 22 To 27
            Worksheets("B_Profit_Loss_Account").Range("C" & i & ":C" & i).value = Worksheets("B1_Profit_Loss_Account_Ext_Ind").Range("R" & i & ":R" & i).value
         Next
         For i = 30 To 32
            Worksheets("B_Profit_Loss_Account").Range("C" & i & ":C" & i).value = Worksheets("B1_Profit_Loss_Account_Ext_Ind").Range("R" & i & ":R" & i).value
         Next
         For i = 37 To 47
            Worksheets("B_Profit_Loss_Account").Range("C" & i & ":C" & i).value = Worksheets("B1_Profit_Loss_Account_Ext_Ind").Range("R" & i & ":R" & i).value
         Next
         For i = 50 To 76
            Worksheets("B_Profit_Loss_Account").Range("C" & i & ":C" & i).value = Worksheets("B1_Profit_Loss_Account_Ext_Ind").Range("R" & i & ":R" & i).value
         Next
         For i = 80 To 83
            Worksheets("B_Profit_Loss_Account").Range("C" & i & ":C" & i).value = Worksheets("B1_Profit_Loss_Account_Ext_Ind").Range("R" & i & ":R" & i).value
         Next
         For i = 86 To 94
            Worksheets("B_Profit_Loss_Account").Range("C" & i & ":C" & i).value = Worksheets("B1_Profit_Loss_Account_Ext_Ind").Range("R" & i & ":R" & i).value
         Next
         For i = 97 To 102
            Worksheets("B_Profit_Loss_Account").Range("C" & i & ":C" & i).value = Worksheets("B1_Profit_Loss_Account_Ext_Ind").Range("R" & i & ":R" & i).value
         Next
         For i = 104 To 104
            Worksheets("B_Profit_Loss_Account").Range("C" & i & ":C" & i).value = Worksheets("B1_Profit_Loss_Account_Ext_Ind").Range("R" & i & ":R" & i).value
         Next
    
    End If
    
  End If
'changes for N sheet --end
Worksheets("B_Profit_Loss_Account").Protect (Pwd)


End Sub

Attribute VB_Name = "Sheet23"
Attribute VB_Base = "0{00020820-0000-0000-C000-000000000046}"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = True
Attribute VB_TemplateDerived = False
Attribute VB_Customizable = True

Attribute VB_Name = "Sheet2"
Attribute VB_Base = "0{00020820-0000-0000-C000-000000000046}"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = True
Attribute VB_TemplateDerived = False
Attribute VB_Customizable = True

Attribute VB_Name = "Sheet11"
Attribute VB_Base = "0{00020820-0000-0000-C000-000000000046}"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = True
Attribute VB_TemplateDerived = False
Attribute VB_Customizable = True
Sub addRow_DtlsIncomePaidAdvance_List()
    Worksheets("I_IT_Payment_Credits").Unprotect (Pwd)
    Call InsertRowsAndFillFormulas("DtlIncomePaid.IncomePaidAdvanceList")
    Worksheets("I_IT_Payment_Credits").Protect (Pwd)
End Sub
Sub addRow_DtlsIncomeSelfAssPmt_List()
    Worksheets("I_IT_Payment_Credits").Unprotect (Pwd)
    Call InsertRowsAndFillFormulas("DtlIncomePaid.IncomeSelfAssPmtList")
    Worksheets("I_IT_Payment_Credits").Protect (Pwd)
End Sub

Private Sub Worksheet_Change(ByVal Target As Range)

    Worksheets("I_IT_Payment_Credits").Activate
    Worksheets("I_IT_Payment_Credits").Unprotect (Pwd)
    Application.EnableEvents = False
    Application.ScreenUpdating = False
    
    If (Target.Columns.count = 1) Then
        Dim cellRow As Integer
        Dim startRow As Integer
        Dim endRow As Integer
        Dim rangeAddress As String
        
        Dim startDate As String
        Dim endDate As String
        Dim StartDepositDate As String
        Dim DsysDate As String
    
        DsysDate = Date
        If (Worksheets("A_Basic_Info").Range("RetInf.RetPeriodFrm").value <> "") Then
            If (TestDate(Worksheets("A_Basic_Info").Range("RetInf.RetPeriodFrm").value) = True) Then
                startDate = CDate(Format(Worksheets("A_Basic_Info").Range("RetInf.RetPeriodFrm").value, "dd/mm/yyyy"))
                DsysDate = CDate(Format(Date, "dd/mm/yyyy"))
            End If
        End If
        
        If (Worksheets("A_Basic_Info").Range("RetInf.RetPeriodTo").value <> "") Then
            If (TestDate(Worksheets("A_Basic_Info").Range("RetInf.RetPeriodTo").value) = True) Then
                endDate = CDate(Format(Worksheets("A_Basic_Info").Range("RetInf.RetPeriodTo").value, "dd/mm/yyyy"))
            End If
        End If
        
        If (Worksheets("A_Basic_Info").Range("RetInf.DepositStartDate").value <> "") Then
            If (TestDate(Worksheets("A_Basic_Info").Range("RetInf.DepositStartDate").value) = True) Then
                StartDepositDate = CDate(Format(Worksheets("A_Basic_Info").Range("RetInf.DepositStartDate").value, "dd/mm/yyyy"))
            End If
        End If
    
        rangeName = Worksheets("I_IT_Payment_Credits").Range("DtlIncomePaid.IncomePaidAdvanceList").Address
        startRow = Worksheets("I_IT_Payment_Credits").Range(rangeName).row
        endRow = Worksheets("I_IT_Payment_Credits").Range(rangeName).Rows.count + startRow - 1
    
        startColumn = Worksheets("I_IT_Payment_Credits").Range(rangeName).column
        lastColumn = startColumn + Worksheets("I_IT_Payment_Credits").Range(rangeName).Columns.count - 1
                         
        For i = startRow To endRow
            Select Case Target.Address
                Case "$B$" & i              'Date From validation
                    If (Target.value <> "") Then
                        result = TestDate(Target.value)
                        If (result = False) Then
                            MsgBox "Please enter date value in dd/mm/yyyy format."
                            Target.value = ""
                            Target.Select
                        Else
                            If (Target.value <> "") Then
                                Dim tValue As String
                                tValue = CDate(Format(Target.value, "dd/mm/yyyy"))
                                If (endDate <> "") Then
                                    If checkFutureDate(Target.value) = False Then
                                        MsgBox "Date of Deposit in Row " & i & " should be on or before current Date."
                                        Target.value = ""
                                        Target.Select
                                    End If
                                Else
                                    MsgBox "Please first enter the Return Period From and Return Period To."
                                    Target.value = ""
                                    Worksheets("A_Basic_Info").Activate
                                    Worksheets("A_Basic_Info").Range("RetInf.RetPeriodFrm").Select
                                    GoTo endSub
                                End If
                            End If
                        End If
                    End If
    
                Case "$A$" & i
                    If Target.value <> "" Then
                        For Each R In Range("DtlIncomePaid.IncomePaidAdvanceList").Rows
                            For Each c In R.Cells
                                If c.Address = Target.Address Then
                                    'Skip comparison with self value
                                Else
                                    If UCase(Target.value <> "") And UCase(c.value) = UCase(Target.value) Then
                                        MsgBox "You have already entered details of PRN " & Target.value & " in Row " & c.row & " in Section I1 : Advance Payment"
                                        Target.value = ""
                                        Target.Select
                                        Exit For
                                        Exit For
                                    End If
                                End If
                            Next
                        Next
                    End If
                    If Target.value <> "" Then
                        For Each R In Range("DtlIncomePaid.IncomeSelfAssPmtList").Rows
                            For Each c In R.Cells
                                If c.Address = Target.Address Then
                                    'Skip comparison with self value
                                Else
                                    If UCase(Target.value) <> "" And UCase(c.value) = UCase(Target.value) Then
                                        MsgBox "You have already entered details of '" & UCase(Target.value) & "' in Row " & c.row & " in Section I2 : Self Assessment Tax"
                                        Target.value = ""
                                        Target.Select
                                        Exit For
                                    End If
                                End If
                            Next
                        Next
                    End If
                    Dim result1 As String
                    If Target.value <> "" Then
                        'InstallmentTax.TaxPaidPRN
                        result1 = validateUniquePRN(Target.value, "InstallmentTax.List", "F_Installment_Tax_Credits")
                        If result1 <> "NE" Then
                            MsgBox "Payment Registration Number is already present in F_Installment_Tax_Credits Row: " & result1
                            Target.value = ""
                            Worksheets("I_IT_Payment_Credits").Activate
                        End If
                        Worksheets("I_IT_Payment_Credits").Activate
                    End If
            End Select
        Next
        '******************************CODE ADDED FOR SELF ASSESMENT PAYMENT IN SECTION I BY Janhavi***************************
        
        rangeName = Worksheets("I_IT_Payment_Credits").Range("DtlIncomePaid.IncomeSelfAssPmtList").Address
        startRow = Worksheets("I_IT_Payment_Credits").Range(rangeName).row
        endRow = Worksheets("I_IT_Payment_Credits").Range(rangeName).Rows.count + startRow - 1
    
        startColumn = Worksheets("I_IT_Payment_Credits").Range(rangeName).column
        lastColumn = startColumn + Worksheets("I_IT_Payment_Credits").Range(rangeName).Columns.count - 1
        'Check For Unique PRN
        'Payment Registration Number Validation same PRN not allowed Start
        If (Application.Intersect(Target.Cells, Range("A" & startRow & ":A" & endRow)) Is Nothing) Then
            'Target Range is not in Given Range
        ElseIf Target.Cells.count = 1 Then
            Dim uCasePRNFlag1 As Integer
            If (uCasePRNFlag1 = 0) Then
                uCasePRNFlag1 = 1
                Target.value = UCase(Target.value)
            End If
            If Target.value <> "" Then
                'For Advance Payment Schedule I1
                For Each R In Range("DtlIncomePaid.IncomePaidAdvanceList").Rows
                    For Each c In R.Cells
                        If c.Address = Target.Address Then
                            'Skip comparison with self value
                        Else
                            If UCase(Target.value) <> "" And UCase(c.value) = UCase(Target.value) Then
                                MsgBox "You have already entered details of '" & UCase(Target.value) & "' in Row " & c.row & " in Section I1 : Advance Payment"
                                Target.value = ""
                                Target.Select
                                Exit For
                            End If
                        End If
                    Next
                Next
            End If
            If Target.value <> "" Then
                'InstallmentTax.TaxPaidPRN
                result1 = validateUniquePRN(Target.value, "InstallmentTax.List", "F_Installment_Tax_Credits")
                If result1 <> "NE" Then
                    MsgBox "Payment Registration Number is already present in F_Installment_Tax_Credits Row: " & result1
                    Target.value = ""
                    Worksheets("I_IT_Payment_Credits").Activate
                End If
                Worksheets("I_IT_Payment_Credits").Activate
            End If
            If Target.value <> "" Then
                'For Self Assesment Payment Schedule I2
                For Each R In Range("DtlIncomePaid.IncomeSelfAssPmtList").Rows
                    For Each c In R.Cells
                        If c.Address = Target.Address Then
                            'Skip comparison with self value
                        Else
                            If UCase(Target.value) <> "" And UCase(c.value) = UCase(Target.value) Then
                                MsgBox "You have already entered details of '" & UCase(Target.value) & "' in Row " & c.row & " in Section I2 : Self Assessment Tax"
                                Target.value = ""
                                Target.Select
                                Exit For
                            End If
                        End If
                    Next
                Next
            End If
        End If
    
        'Date Validation for Date of Deposit after Return period end date to current date
        If (Application.Intersect(Target.Cells, Range("B" & startRow & ":B" & endRow)) Is Nothing) Then
            'Target Range is not in Given Range
        ElseIf Target.Cells.count = 1 Then
            If (Target.value <> "") Then
                result = TestDate(Target.value)
                If (result = False) Then
                    MsgBox "Please enter date value in dd/mm/yyyy format."
                    Target.value = ""
                    Target.Select
                Else
                    If (Target.value <> "") Then
                        tValue = CDate(Format(Target.value, "dd/mm/yyyy"))
                        If (endDate <> "" And startDate <> "") Then
                            If checkFutureDate(Target.value) = False Or DateValue(tValue) <= DateValue(endDate) Then
                                MsgBox "Date of Deposit in Row " & i & " should be between after Return Period and Current Date"
                                Target.value = ""
                                Target.Select
                            End If
                        Else
                            MsgBox "Please first enter the Return Period From and Return Period To."
                            Target.value = ""
                            Target.Select
                            Worksheets("A_Basic_Info").Activate
                            Worksheets("A_Basic_Info").Range("SecA.RtnPdFrom").Select
                            GoTo endSub
                        End If
                    End If
                End If
            End If
        End If
        'Date Validation for Date of Deposit after Return period end date to current date
        '******************************END**************************************************************************************
    
        'new code added for Bank Section Enable/Disable Start
'        If Worksheets("M_Tax_Computation").Range("FinalTax.TaxRefundDue").value <> "" Then
'            If Worksheets("M_Tax_Computation").Range("FinalTax.TaxRefundDue").value < 0 Then
'                If Worksheets("A_Basic_Info").Range("BankName").Locked = True Then
'                    Call lockUnlock_cell_rng("A_Basic_Info", "BankName", False)
'                    Call lockUnlock_cell_rng("A_Basic_Info", "BankBranchName", False)
'                    Call lockUnlock_cell_rng("A_Basic_Info", "BankDtl.City", False)
'                    Call lockUnlock_cell_rng("A_Basic_Info", "BankDtl.AccName", False)
'                    Call lockUnlock_cell_rng("A_Basic_Info", "BankDtl.AccNumber", False)
'                End If
'            Else
'                If Worksheets("A_Basic_Info").Range("BankName").Locked = False Then
'                    Call lockUnlock_cell_rng("A_Basic_Info", "BankName", True)
'                    Call lockUnlock_cell_rng("A_Basic_Info", "BankBranchName", True)
'                    Call lockUnlock_cell_rng("A_Basic_Info", "BankDtl.City", True)
'                    Call lockUnlock_cell_rng("A_Basic_Info", "BankDtl.AccName", True)
'                    Call lockUnlock_cell_rng("A_Basic_Info", "BankDtl.AccNumber", True)
'                End If
'            End If
'            Worksheets("I_IT_Payment_Credits").Activate
'        End If
        'new code added for Bank Section Enable/Disable End
    End If
endSub:
    Worksheets("I_IT_Payment_Credits").Protect (Pwd)
    Application.EnableEvents = True
    Application.ScreenUpdating = True
End Sub

Attribute VB_Name = "Sheet17"
Attribute VB_Base = "0{00020820-0000-0000-C000-000000000046}"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = True
Attribute VB_TemplateDerived = False
Attribute VB_Customizable = True


Attribute VB_Name = "Sheet5"
Attribute VB_Base = "0{00020820-0000-0000-C000-000000000046}"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = True
Attribute VB_TemplateDerived = False
Attribute VB_Customizable = True

Attribute VB_Name = "Sheet22"
Attribute VB_Base = "0{00020820-0000-0000-C000-000000000046}"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = True
Attribute VB_TemplateDerived = False
Attribute VB_Customizable = True
Sub addRow_Rent_PaidPayble_ListPartI()
    Worksheets("A_Basic_Info").Unprotect (Pwd)
    Call InsertRowsAndFillFormulas("RentPaid.RentList")
    Worksheets("A_Basic_Info").Protect (Pwd)
End Sub
Sub addRow_Schedule2_RentalList()
    Worksheets("A_Basic_Info").Unprotect (Pwd)
    Call InsertRowsAndFillFormulas("RentalIncome.List")
    Worksheets("A_Basic_Info").Protect (Pwd)
End Sub
Private Sub Worksheet_Change(ByVal Target As Range)

    Worksheets("A_Basic_Info").Activate
    Worksheets("A_Basic_Info").Unprotect (Pwd)
    Application.EnableEvents = False
    Application.ScreenUpdating = False
    
    Dim endDate As String
    Dim lockCell As Boolean
    
    If (Target.Columns.count = 1) Then
        PINNo = Worksheets("A_Basic_Info").Range("RetInf.PIN").value

        If (Worksheets("A_Basic_Info").Range("RetInf.RetPeriodFrm").value <> "") Then
            If (TestDate(Worksheets("A_Basic_Info").Range("RetInf.RetPeriodFrm").value) = True) Then
                startDate = CDate(Format(Worksheets("A_Basic_Info").Range("RetInf.RetPeriodFrm").value, "dd/mm/yyyy"))
            End If
        End If

        If (Worksheets("A_Basic_Info").Range("RetInf.RetPeriodTo").value <> "") Then
            If (TestDate(Worksheets("A_Basic_Info").Range("RetInf.RetPeriodTo").value) = True) Then
                endDate = CDate(Format(Worksheets("A_Basic_Info").Range("RetInf.RetPeriodTo").value, "dd/mm/yyyy"))
            End If
        End If
        
        If (Worksheets("A_Basic_Info").Range("RtnInf.RtnPrdToActStart").value <> "") Then
            If (TestDate(Worksheets("A_Basic_Info").Range("RtnInf.RtnPrdToActStart").value) = True) Then
                RPToActStart = CDate(Format(Worksheets("A_Basic_Info").Range("RtnInf.RtnPrdToActStart").value, "dd/mm/yyyy"))
            End If
        End If
    
        If (Worksheets("A_Basic_Info").Range("RtnInf.RtnPrdToAct").value <> "") Then
            If (TestDate(Worksheets("A_Basic_Info").Range("RtnInf.RtnPrdToAct").value) = True) Then
                RPToAct = CDate(Format(Worksheets("A_Basic_Info").Range("RtnInf.RtnPrdToAct").value, "dd/mm/yyyy"))
            End If
        End If
        If (Worksheets("A_Basic_Info").Range("RetInf.dateforAuditCertificate").value <> "") Then
            If (TestDate(Worksheets("A_Basic_Info").Range("RetInf.dateforAuditCertificate").value) = True) Then
                auditEndDate = CDate(Format(Worksheets("A_Basic_Info").Range("RetInf.dateforAuditCertificate").value, "dd/mm/yyyy"))
            End If
        End If
        If (Worksheets("A_Basic_Info").Range("RetInf.dateforAuditStartDt").value <> "") Then
            If (TestDate(Worksheets("A_Basic_Info").Range("RetInf.dateforAuditStartDt").value) = True) Then
                auditStartDate = CDate(Format(Worksheets("A_Basic_Info").Range("RetInf.dateforAuditStartDt").value, "dd/mm/yyyy"))
            End If
        End If
        If (Worksheets("A_Basic_Info").Range("RetInf.EffectvLstDate").value <> "") Then
            If (TestDate(Worksheets("A_Basic_Info").Range("RetInf.EffectvLstDate").value) = True) Then
                effectiveLstDate = CDate(Format(Worksheets("A_Basic_Info").Range("RetInf.EffectvLstDate").value, "dd/mm/yyyy"))
            End If
        End If

        If Target.Address = "$B$5" Then
            If (Target.value <> "") Then
                DsysDate = Date
                
                If TestDate(Target.value) = False Then
                    MsgBox "Please enter date value in dd/mm/yyyy format."
                    Target.value = ""
                    Target.Select
                    GoTo endSub
                Else
                    If (TestDateLimit(Target.value) = False) Then
                        MsgBox "Please enter date in Return Period From with year on or after 2001."
                        Target.value = ""
                        Target.Select
                        GoTo endSub
                    End If
                    If (DateValue(startDate) > DateValue(DsysDate)) Then
                        MsgBox "You cannot file the return for the period whose date of Return Period From and / or Return Period To is a future date."
                        Target.value = ""
                        Target.Select
                        GoTo endSub
                    End If
                    Dim rtnPrdFrom As String
                    Dim rtnPrdTo As String
                    Dim rtnDepositDate As String
                    Dim mon As String
                    Dim mmU As String
                    Dim year As String
                    Dim Depstyear As String
                    Dim arrearyear As String
                    Dim str As String
                    rtnPrdFrom = Target.value
                    dd = Format(CDate(Trim(startDate)), "DD")
                    mm = Format(CDate(Trim(startDate)), "MM")
                    mmU = Format(CDate(Trim(startDate)), "MM")
                    year = Format(CDate(Trim(startDate)), "YYYY")
                    Dim rtnTo  As String
                    
                    'added on 01/03/2021 by Ruth, Kiptubei and lawrence to change field names dynamically in year >=2021
                    
                    Worksheets("F_Installment_Tax_Credits").Unprotect (Pwd)
                    Worksheets("M_Tax_Computation").Unprotect (Pwd)
                    If year >= 2021 Then
                        Worksheets("F_Installment_Tax_Credits").Range("A1").value = "Section F : Details of Installment/Minimum Tax Paid"
                        Worksheets("F_Installment_Tax_Credits").Range("C2").value = "Amount of Installment/Minimum Tax Paid (Ksh)"
                        'Worksheets("M_Tax_Computation").Rows("87:87").Hidden = False
                        Worksheets("M_Tax_Computation").Range("TaxComp.instTaxPaidLbl").value = "Total Installment Tax Paid (Total of 'Amount of Installment/Minimum Tax Paid' from F_Installment_Tax_Credits)"
                        'Worksheets("M_Tax_Computation").Range("B82").value = "Total Installment Tax Paid (Total of 'Amount of Installment/Minimum Tax Paid' from F_Installment_Tax_Credits)"
                    Else
                        Worksheets("F_Installment_Tax_Credits").Range("A1").value = "Section F : Details of Installment Tax Paid"
                        Worksheets("F_Installment_Tax_Credits").Range("C2").value = "Amount of Installment Tax Paid (Ksh)"
                        Worksheets("M_Tax_Computation").Range("TaxComp.instTaxPaidLbl").value = "Total Installment Tax Paid (Total of ' Amount of Installment Tax Paid' from F_Installment_Tax_Credits)"
                        'Worksheets("M_Tax_Computation").Range("B82").value = "Total Installment Tax Paid (Total of ' Amount of Installment Tax Paid' from F_Installment_Tax_Credits)"
                        'Worksheets("M_Tax_Computation").Rows("87:87").Hidden = True
                        'Worksheets("M_Tax_Computation").Range("C87").value = 0#
                    End If
                    Worksheets("F_Installment_Tax_Credits").Protect (Pwd)
                    Worksheets("M_Tax_Computation").Protect (Pwd)
                    
                    'end 01/03/2021
                    
                    If (mm - 1) = 0 Then
                        mon = "12"
                    Else
                        mm = mm - 1
                        If (Len(mm) = 1) Then
                            mon = "0" & mm
                        Else
                            mon = mm
                        End If
                    End If
                    If (mon = "12") Then
                        rtnTo = mon & "/" & year
                    Else
                        rtnTo = mon & "/" & year + 1
                    End If
                    Depstyear = dd & "/" & mmU & "/" & year - 1
                    ActiveSheet.Unprotect (Pwd)
                    If IsDate("31/" & rtnTo) Then
                        Worksheets("A_Basic_Info").Range("RtnInf.RtnPrdToAct").value = "31/" & rtnTo
                    ElseIf IsDate("30/" & rtnTo) Then
                        Worksheets("A_Basic_Info").Range("RtnInf.RtnPrdToAct").value = "30/" & rtnTo
                    ElseIf IsDate("29/" & rtnTo) Then
                        Worksheets("A_Basic_Info").Range("RtnInf.RtnPrdToAct").value = "29/" & rtnTo
                    ElseIf IsDate("28/" & rtnTo) Then
                        Worksheets("A_Basic_Info").Range("RtnInf.RtnPrdToAct").value = "28/" & rtnTo
                    End If
                    Worksheets("A_Basic_Info").Range("RetInf.DepositStartDate").value = Depstyear
                    Worksheets("A_Basic_Info").Range("RetInf.YearIncomeFD").value = year
                    Worksheets("A_Basic_Info").Range("RetInf.Month").value = mmU
                    Worksheets("A_Basic_Info").Range("RtnInf.RtnPrdToActStart").value = "01" & "/" & mmU & "/" & year
                    mon = 0
                    retPeriodTo = CDate(Format((Worksheets("A_Basic_Info").Range("RtnInf.RtnPrdToAct").value), "dd/mm/yyyy"))
                    mm = Format(CDate(Trim(retPeriodTo)), "MM")
                    dd = Format(CDate(Trim(retPeriodTo)), "dd")
                    year = Format(CDate(Trim(retPeriodTo)), "yyyy")
                    
                    'by Palak
                    'Commented on 01/03/2021 by Ruth, Kiptubei and lawrence to include month
                    'If year >= 2020 Then
                    '
                    If ((year >= 2020 And mm >= "04") Or (year >= 2021)) Then
                        ActiveWorkbook.Unprotect (Pwd)
                        Worksheets("E2_CA_WTA_SLM").Unprotect (Pwd)
                        Worksheets("E2_CA_WTA_SLM").Visible = xlSheetHidden
                        Call lockUnlock_cell_rng("E2_CA_WTA_SLM", "WAT.ListB", True, "10")
                        Worksheets("E2_CA_WTA_SLM").Protect (Pwd)
                        Worksheets("E2_CA_WTA_WDV").Unprotect (Pwd)
                        Worksheets("E2_CA_WTA_WDV").Range("B4").value = 50
                        Worksheets("E2_CA_WTA_WDV").Range("C4").value = 25
                        
                        'Commented and added on 01/03/2021 by Ruth, Kiptubei and Lawrence to set to 0.0 if greyed out
                        
                        'Worksheets("E2_CA_WTA_WDV").Range("D4").value = 10
                        'Worksheets("E2_CA_WTA_WDV").Range("E4").value = 10
                        Worksheets("E2_CA_WTA_WDV").Range("D4").value = 0#
                        Worksheets("E2_CA_WTA_WDV").Range("E4").value = 0#
                        
                        'end 01/03/2021
                        
                        Worksheets("E2_CA_WTA_WDV").Protect (Pwd)
                    Else
                     ActiveWorkbook.Unprotect (Pwd)
                        Worksheets("E2_CA_WTA_SLM").Unprotect (Pwd)
                        Worksheets("E2_CA_WTA_SLM").Visible = xlSheetVisible
                        Call lockUnlock_cell_rng("E2_CA_WTA_SLM", "WAT.ListB", False, "10")
                        Worksheets("E2_CA_WTA_SLM").Protect (Pwd)
                        
                        Worksheets("E2_CA_WTA_WDV").Unprotect (Pwd)
                        Worksheets("E2_CA_WTA_WDV").Range("B4").value = 35
                        Worksheets("E2_CA_WTA_WDV").Range("C4").value = 30
                        
                        'Commented and added on 01/03/2021 by Ruth, Kiptubei and Lawrence to set to 0.0 if greyed out
                                                
                        'Worksheets("E2_CA_WTA_WDV").Range("D4").value = 25
                        'Worksheets("E2_CA_WTA_WDV").Range("E4").value = 12.5

                        If year >= 2021 Then
                            Worksheets("E2_CA_WTA_WDV").Range("D4").value = 0#
                            Worksheets("E2_CA_WTA_WDV").Range("E4").value = 0#
                        Else
                            Worksheets("E2_CA_WTA_WDV").Range("D4").value = 25
                            Worksheets("E2_CA_WTA_WDV").Range("E4").value = 12.5
                        End If
                        
                       'end 01/03/2021
                       
                        Worksheets("E2_CA_WTA_WDV").Protect (Pwd)
                    
                    End If
…