You are on page 1of 16

Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)

Dim nFinalRow As Integer


Dim nFinalRowPaymentsToday As Integer
Dim nPasteRowPaymentsToday As Integer
Dim rg As Range

On Error Resume Next


nFinalRow = Cells(Rows.Count, 3).End(xlUp).Row

If Not Intersect(Target, Range("C7:C" & nFinalRow)) Is Nothing Then


Application.ScreenUpdating = False
Application.EnableEvents = False
Application.Calculation = xlCalculationManual

Sheets("Payments_Today").Range("C1").Value = 0
Sheets("Payments_Today").Range("D1").Value = 0
Cancel = True

If Cells(Selection.Row, 22).Value > 0 Then


Dim cell As Range
Sheets("Payments_Today").Range("F7:L106").ClearContents
Sheets("Payments_Today").Range("G7:I106").FormatConditions.Delete

nFinalRowPaymentsToday = Sheets("Payments_Today").Cells(Rows.Count, 5).End(xlUp).Row


For Each cell In Sheets("Payments_Today").Range("E7:E" & nFinalRowPaymentsToday)
If cell.Value = Selection.Value Then
cell.ClearContents
nFinalRowPaymentsToday = Sheets("Payments_Today").Cells(Rows.Count, 5).End(xlUp).Row
Set rg = Sheets("Payments_Today").Range("E6:E" & nFinalRowPaymentsToday)
rg.Sort Key1:=Sheets("Payments_Today").Range("E7"), Order1:=xlAscending, Header:=xlYes
End If
Next
Else
Sheets("Payments_Today").Range("F7:L106").ClearContents
Sheets("Payments_Today").Range("G7:I106").FormatConditions.Delete

nPasteRowPaymentsToday = Sheets("Payments_Today").Cells(Rows.Count, 5).End(xlUp).Row + 1


If nPasteRowPaymentsToday = 5 Then
Sheets("Payments_Today").Range("E7").Value = Selection.Value
Else
Sheets("Payments_Today").Range("E" & nPasteRowPaymentsToday).Value = Selection.Value
End If
If nPasteRowPaymentsToday > 7 Then
Sheets("Payments_Today").Range("E6:E" & nPasteRowPaymentsToday).RemoveDuplicates Columns:=Array(1), Header:=xlYes
End If

Set rg = Sheets("Payments_Today").Range("E6:E" & nPasteRowPaymentsToday)


rg.Sort Key1:=Sheets("Payments_Today").Range("E7"), Order1:=xlAscending, Header:=xlYes
Sheets("Payments_Today").Range("E7").Copy
Sheets("Payments_Today").Range("E7:E106").PasteSpecial Paste:=xlPasteFormats
End If

Application.CutCopyMode = False
Application.Calculation = xlCalculationAutomatic
Application.EnableEvents = True
Application.ScreenUpdating = True
End If

End Sub

Private Sub Worksheet_Deactivate()


If Sheets("GL").AutoFilterMode = False Then
Sheets("GL").Range("A6").CurrentRegion.AutoFilter
Else
On Error Resume Next
Sheets("GL").ShowAllData
End If
End Sub
Private Sub Worksheet_Activate()

Dim nFinalRow As Integer


nFinalRow = Cells(Rows.Count, 5).End(xlUp).Row

If nFinalRow > 6 And Range("D1").Value = 0 Then


Application.ScreenUpdating = False
Application.EnableEvents = False

Range("J7:J106").ClearContents
Range("D6:E" & nFinalRow).Copy Destination:=Range("K6")
Sheets("GL").Range("A6").CurrentRegion.AdvancedFilter Action:=xlFilterCopy, _
CriteriaRange:=Range("K6:L" & nFinalRow), _
CopyToRange:=Range("E6:I6"), _
Unique:=True
Sheets("GL").Range("A6").CurrentRegion.AutoFilter

Call update_formats_payments_today

Range("D1").Value = 1

Range("E7").Select
ActiveWindow.ScrollRow = 1

Application.CutCopyMode = False
Application.EnableEvents = True
Application.ScreenUpdating = True
End If

End Sub

Private Sub Worksheet_Change(ByVal Target As Range)

Dim nFinalRow As Integer


nFinalRow = Cells(Rows.Count, 5).End(xlUp).Row

Application.ScreenUpdating = False
Application.EnableEvents = False

If nFinalRow > 6 Then


If Not Intersect(Target, Range("E7:E106")) Is Nothing Then
cAddress = Selection.Address

Range("J7:J106").ClearContents
Range("D6:E" & nFinalRow).Copy Destination:=Range("K6")
Sheets("GL").Range("A6").CurrentRegion.AdvancedFilter Action:=xlFilterCopy, _
CriteriaRange:=Range("K6:L" & nFinalRow), _
CopyToRange:=Range("E6:I6"), _
Unique:=True

Call update_formats_payments_today

Range("C1").Value = 0
Range(cAddress).Select
End If
If Not Intersect(Target, Range("G7:I" & nFinalRow)) Is Nothing Then
cAddress = Selection.Address

Call update_beneficiaries
Call update_formats_payments_today

Range("C1").Value = 0
Range(cAddress).Select
End If

If Not Intersect(Target, Range("J7:J" & nFinalRow)) Is Nothing Then


cAddress = Selection.Address

Call update_beneficiaries
Call update_formats_payments_today

Range(cAddress).Select
End If
End If

Application.CutCopyMode = False
Application.EnableEvents = True
Application.ScreenUpdating = True

End Sub
Sub set_sub_totals_GL()

If ActiveSheet.Name = "GL" And Range("A2").Value = 0 Then


On Error Resume Next
'Application.ScreenUpdating = False
Range("C6").Select
Range("A6").CurrentRegion.AutoFilter

Set rg = Range("A6").CurrentRegion
rg.Sort Key1:=Range("C7"), Key2:=Range("H7"), Order1:=xlAscending, Order2:=xlDescending, Header:=xlYes

Range("A6").CurrentRegion.Subtotal GroupBy:=3, Function:=xlSum, TotalList:=Array(13), SummaryBelowData:=True, Replace:=True


'=== set_format
Range("A6").CurrentRegion.AutoFilter Field:=1, Criteria1:="="

ActiveSheet.Outline.ShowLevels RowLevels:=2
Range("A6").CurrentRegion.SpecialCells(xlCellTypeVisible).Font.Bold = True
With Range("A6").CurrentRegion.SpecialCells(xlCellTypeVisible).Interior
.PatternColorIndex = xlAutomatic
.ThemeColor = xlThemeColorDark1
.TintAndShade = -0.149998474074526
.PatternTintAndShade = 0
End With
ActiveSheet.Outline.ShowLevels RowLevels:=3

ActiveSheet.ShowAllData

Range("A6").CurrentRegion.ClearOutline
Range("C6").Select
Columns("C:C").NumberFormat = "General"
Range("A2").Value = 1
'Application.ScreenUpdating = True
End If

End Sub
Sub update_beneficiaries()

Application.Calculation = xlCalculationManual

Dim rngFilter As Range


Dim myTable As ListObject
Dim rng As Range
Dim nPasteRowBeneficiaries As Integer
Dim nFinalRow As Integer

nFinalRow = Cells(Rows.Count, 5).End(xlUp).Row


Set rngFilter = Range("N6:N" & nFinalRow)

Set myTable = Sheets("Beneficiaries").ListObjects(1)


With myTable.Range
Set rng = .Offset(1).Resize(.Rows.Count - 1).SpecialCells(xlCellTypeVisible)
.AdvancedFilter Action:=xlFilterInPlace, CriteriaRange:=rngFilter
rng.Delete
.AutoFilter
End With

nPasteRowBeneficiaries = Sheets("Beneficiaries").Cells(Rows.Count, 1).End(xlUp).Row + 1


Range("F7:J" & nFinalRow).Copy Destination:=Sheets("Beneficiaries").Range("A" & nPasteRowBeneficiaries)
Sheets("Beneficiaries").Range("Table1[#All]").RemoveDuplicates Columns:=1, Header:=xlYes
Sheets("Beneficiaries").Cells.FormatConditions.Delete

Set rg = Sheets("Beneficiaries").Range("Table1[#All]")
rg.Sort Key1:=Sheets("Beneficiaries").Range("A5"), Order1:=xlAscending, Header:=xlYes

Application.Calculation = xlCalculationAutomatic

End Sub

Sub Update_data_2()

If Range("E7").Value <> "" And Range("B1").Value = 1 Then


'If Left(ThisWorkbook.Path, 34) = "D:\Dropbox\RutgersWPF\REPORTS_2020" Then
Application.ScreenUpdating = False
Application.DisplayAlerts = False
Application.EnableEvents = False
Application.Calculation = xlCalculationManual

On Error Resume Next

Sheets("Payments_Today").Range("A1").Value = 1
Sheets("Payments_Today").Range("C1").Value = 1

Sheets("GL").Select
Range("A6").AutoFilter
Range("A6").AutoFilter
ActiveSheet.ShowAllData

Call get_Items_Data
Call get_Exchange_Rate_Data
Call get_Selected_GL
Call get_Suppliers

Application.Calculation = xlCalculationAutomatic
Application.CutCopyMode = False
Application.DisplayAlerts = True
Application.EnableEvents = True
Application.ScreenUpdating = True
'End If

Application.ScreenUpdating = False
Call set_GL
Application.ScreenUpdating = True
End If

End Sub

Sub Update_data_1()

'If Left(ThisWorkbook.Path, 34) = "D:\Dropbox\RutgersWPF\REPORTS_2020" Then


Application.ScreenUpdating = False
Application.DisplayAlerts = False
Application.EnableEvents = False
Application.Calculation = xlCalculationManual

On Error Resume Next


Sheets("Payments_Today").Range("A1").Value = 0
Sheets("Payments_Today").Range("C1").Value = 0
Sheets("Payments_Today").Range("D1").Value = 0

Sheets("GL").Select
Range("A6").AutoFilter
Range("A6").AutoFilter
ActiveSheet.ShowAllData

Call get_Items_Data
Call get_Exchange_Rate_Data
Call get_Selected_GL
Call get_Suppliers

Application.Calculation = xlCalculationAutomatic
Application.CutCopyMode = False
Application.DisplayAlerts = True
Application.EnableEvents = True
Application.ScreenUpdating = True
'End If

Application.ScreenUpdating = False
Call set_GL
Application.ScreenUpdating = True

End Sub

Sub get_Suppliers()

Dim PasteRowSuppliers As Integer


Dim FinalRowSuppliers As Integer
Dim rg As Range

On Error Resume Next


Sheets("Criteria").Range("G4").CurrentRegion.AdvancedFilter Action:=xlFilterCopy, _
CriteriaRange:=Sheets("Criteria").Range("E4:E5"), _
CopyToRange:=Sheets("Beneficiaries").Range("G4"), _
Unique:=True

FinalRowSuppliers = Sheets("Beneficiaries").Cells(Rows.Count, 7).End(xlUp).Row


PasteRowSuppliers = Sheets("Beneficiaries").Cells(Rows.Count, 1).End(xlUp).Row + 1

Sheets("Beneficiaries").Range("G5:G" & FinalRowSuppliers).Copy Destination:=Sheets("Beneficiaries").Range("A" & PasteRowSuppliers)


Sheets("Beneficiaries").Range("Table1[#All]").RemoveDuplicates Columns:=1, Header:=xlYes
Sheets("Beneficiaries").Range("G5:G10000").ClearContents

Set rg = Sheets("Beneficiaries").Range("Table1[#All]")
rg.Sort Key1:=Sheets("Beneficiaries").Range("A5"), Order1:=xlAscending, Header:=xlYes

End Sub

Sub get_Items_Data()

Dim ReportWB As Workbook


Dim SourceWB As Workbook
Dim cFolderPath As String

Set ReportWB = ActiveWorkbook


'cFolderPath = "D:\Dropbox\RutgersWPF\_UPDATE_FILES"
cFolderPath = "D:\OneDrive\RutgersWPF"

On Error Resume Next


Set SourceWB = Workbooks.Open(cFolderPath & "\_data_exact\_Items.xlsx")

If Not SourceWB Is Nothing Then


ActiveSheet.Columns("A:D").Copy Destination:=ReportWB.Sheets("Lookups").Range("K1")
SourceWB.Close False
End If

End Sub

Sub get_Exchange_Rate_Data()

Dim ReportWB As Workbook


Dim SourceWB As Workbook
Dim cFolderPath As String

Set ReportWB = ThisWorkbook


cFolderPath = "D:\OneDrive\RutgersWPF"

On Error Resume Next


Set SourceWB = Workbooks.Open(cFolderPath & "\_data_others\_Exchange_Rates.xlsx")

If Not SourceWB Is Nothing Then


ActiveSheet.Cells.Copy Destination:=ReportWB.Sheets("Exchange_Rates").Range("A1")
SourceWB.Close False
End If

End Sub

Sub Clean_data()

On Error Resume Next


If Range("A1").Value <> "Journal" And Left(ActiveWorkbook.Name, 16) = "_GL_ID_Purchases" Then
Rows("1:3").Delete
Rows("2:2").Delete
Rows(Cells(Rows.Count, 1).End(xlUp).Row).Delete
FinalRowData = Cells(Rows.Count, 1).End(xlUp).Row
Application.Calculation = xlCalculationAutomatic
Range("P2").FormulaR1C1 = "=TRIM(RC[-9])"
Range("P2").Copy Destination:=Range("P2:P" & FinalRowData)
Range("P2:P" & FinalRowData).Copy
Range("G2").PasteSpecial Paste:=xlPasteValues
Columns("P:P").Clear
Range("A1").Select
Application.CutCopyMode = False
Application.Calculation = xlCalculationManual
ActiveWorkbook.Save
End If

If Range("A1").Value <> "Journal" And Left(ActiveWorkbook.Name, 19) = "_GL_ID_Entry_Number" Then


Rows("1:4").Delete
Rows("2:2").Delete
Rows(Cells(Rows.Count, 1).End(xlUp).Row).Delete
FinalRowData = Cells(Rows.Count, 1).End(xlUp).Row
Application.Calculation = xlCalculationAutomatic
Range("P2").FormulaR1C1 = "=TRIM(RC[-9])"
Range("P2").Copy Destination:=Range("P2:P" & FinalRowData)
Range("P2:P" & FinalRowData).Copy
Range("G2").PasteSpecial Paste:=xlPasteValues
Columns("P:P").Clear
Range("A1").Select
Application.CutCopyMode = False
Application.Calculation = xlCalculationManual
ActiveWorkbook.Save
End If

If Left(ActiveWorkbook.Name, 6) = "_Pivot" Then


Rows("1:2").UnMerge
Range("A5").CurrentRegion.Select
ActiveWorkbook.Save
End If

End Sub

Sub get_Selected_GL()

Dim ReportWB As Workbook


Dim SourceWB As Workbook
Dim cFolderPath As String
Dim n As Integer
Dim FinalRowData As Integer

Set ReportWB = ThisWorkbook


n=0

On Error Resume Next


' Laptop Darma dan Mifta
Set SourceWB = Workbooks.Open("C:\OneDrive\RutgersWPF\_data_exact\_GL_ID_Purchases.xlsx")

' Laptop Deka


If SourceWB Is Nothing Then
Set SourceWB = Workbooks.Open("C:\Users\User\OneDrive\RutgersWPF\_data_exact\_GL_ID_Purchases.xlsx")
End If

' Laptop Adi


If SourceWB Is Nothing Then
Set SourceWB = Workbooks.Open("D:\OneDrive\RutgersWPF\_data_exact\_GL_ID_Entry_Number_2021.xlsx")
n=1
End If

If Not SourceWB Is Nothing Then


ReportWB.Sheets("GL").ShowAllData
ReportWB.Sheets("GL").Range("A2").Value = 0
ReportWB.Sheets("GL").Range("A7:V10000").Clear
'ReportWB.Sheets("Criteria").Range("G6:Y20000").Clear

Call Clean_data
ActiveSheet.Range("A1").CurrentRegion.AdvancedFilter Action:=xlFilterCopy, CopyToRange:=ReportWB.Sheets("Criteria").Range("G4:R4")
Call Delete_Names
SourceWB.Close False

FinalRowData = Sheets("Criteria").Cells(Rows.Count, 7).End(xlUp).Row


Sheets("Criteria").Range("G3:Y3").Copy
Sheets("Criteria").Range("G5:Y" & FinalRowData).PasteSpecial Paste:=xlPasteFormats

Application.Calculation = xlCalculationAutomatic
Sheets("Criteria").Range("S5:Y5").Copy Destination:=Sheets("Criteria").Range("S5:Y" & FinalRowData)

If Sheets("Payments_Today").Range("A1").Value = 1 Then
Dim nFinalRow As Integer
nFinalRow = Sheets("Payments_Today").Cells(Rows.Count, 5).End(xlUp).Row

Sheets("Criteria").Range("G4").CurrentRegion.AdvancedFilter Action:=xlFilterCopy, _
CriteriaRange:=Sheets("Payments_Today").Range("D6:E" & nFinalRow), _
CopyToRange:=Sheets("GL").Range("A6:R6")
Sheets("Payments_Today").Range("D6:E" & nFinalRow).Copy Destination:=Sheets("Payments_Today").Range("K6")
Sheets("Payments_Today").Range("F7:F" & nFinalRow).Copy Destination:=Sheets("Payments_Today").Range("N7")
Sheets("Criteria").Range("G4").CurrentRegion.AdvancedFilter Action:=xlFilterCopy, _
CriteriaRange:=Sheets("Payments_Today").Range("K6:L" & nFinalRow), _
CopyToRange:=Sheets("Payments_Today").Range("E6:I6"), _
Unique:=True

Sheets("Payments_Today").Range("G7:I106").FormatConditions.Delete
Sheets("Payments_Today").Range("L3").Copy
Sheets("Payments_Today").Range("E7:E106").PasteSpecial Paste:=xlPasteFormats
Sheets("Payments_Today").Range("G3:I3").Copy
Sheets("Payments_Today").Range("G7:I" & nFinalRow).PasteSpecial Paste:=xlPasteFormats
Sheets("Payments_Today").Range("J1").Copy Destination:=Sheets("Payments_Today").Range("J7:J" & nFinalRow)
Sheets("Payments_Today").Range("J7:J" & nFinalRow).Copy
Sheets("Payments_Today").Range("J7:J" & nFinalRow).PasteSpecial Paste:=xlPasteValues
Sheets("Payments_Today").Range("N1").Copy Destination:=Sheets("Payments_Today").Range("N7:N" & nFinalRow)
Sheets("Payments_Today").Range("E7").Copy
Sheets("Payments_Today").Range("E7").PasteSpecial Paste:=xlPasteValues
Else
If n = 1 Then ' Laptop Adi
Sheets("Criteria").Range("G4").CurrentRegion.AdvancedFilter Action:=xlFilterCopy, _
CriteriaRange:=Sheets("Criteria").Range("A4").CurrentRegion, _
CopyToRange:=Sheets("GL").Range("A6:R6")
Else ' Laptop Others
Sheets("Criteria").Range("G4").CurrentRegion.AdvancedFilter Action:=xlFilterCopy, _
CopyToRange:=Sheets("GL").Range("A6:R6")
End If
End If

Range("A6").CurrentRegion.Rows.AutoFit
Call Delete_Names
End If

End Sub

Sub set_GL()

On Error Resume Next


FinalRowDataGL = Cells(Rows.Count, 1).End(xlUp).Row
Range("C1").Copy
Range("C7:C" & FinalRowDataGL).PasteSpecial Paste:=xlPasteFormats
Range("P1:V1").Copy
Range("P7:V" & FinalRowDataGL).PasteSpecial Paste:=xlPasteFormats

Range("F1").Copy Destination:=Range("F7:F" & FinalRowDataGL)


Range("I1").Copy Destination:=Range("I7:I" & FinalRowDataGL)
Range("S1:V1").Copy Destination:=Range("S7:V" & FinalRowDataGL)

Sheets("Criteria").Range("G6:Y20000").Clear
Range("F4").Value = "(All)"

ActiveSheet.ShowAllData

Call set_sub_totals_GL

Columns("C:C").Replace What:=" Total", Replacement:="", LookAt:=xlPart, SearchOrder:=xlByRows


FinalRowDataGL = Cells(Rows.Count, 3).End(xlUp).Row
Rows(FinalRowDataGL).Clear

ActiveSheet.ShowAllData

Range("A6").CurrentRegion.AdvancedFilter Action:=xlFilterCopy, CopyToRange:=Sheets("Lookups").Range("R1"), Unique:=True


FinalRowDataLookup = Sheets("Lookups").Cells(Rows.Count, 18).End(xlUp).Row
Sheets("Lookups").Range("R" & FinalRowDataLookup + 1).Value = "(All)"
Set rg = Sheets("Lookups").Range("R1").CurrentRegion
rg.Sort Key1:=Sheets("Lookups").Range("R2"), Order1:=xlAscending, Header:=xlYes

ActiveSheet.ShowAllData
Range("A6").AutoFilter

End Sub
Sub update_formats_payments_today()

Dim nFinalRow As Integer

nFinalRow = Cells(Rows.Count, 5).End(xlUp).Row

Range("L3").Copy
Range("E7:E106").PasteSpecial Paste:=xlPasteFormats
Range("G7:I106").FormatConditions.Delete
Range("G3:I3").Copy
Range("G7:I" & nFinalRow).PasteSpecial Paste:=xlPasteFormats
Range("J1").Copy Destination:=Range("J7:J" & nFinalRow)
Range("J7:J" & nFinalRow).Copy
Range("J7:J" & nFinalRow).PasteSpecial Paste:=xlPasteValues
Range("N1").Copy Destination:=Range("N7:N" & nFinalRow)

End Sub

Sub create_files_PDF()

If Range("F4").Value = "(All)" And Range("B4").Value = 0 Then


Application.ScreenUpdating = False
Application.EnableEvents = False
Application.DisplayAlerts = False
'Sheets("Voucher").Visible = True

Dim Destwb As Workbook


Dim FolderName As String
Dim FileName As String

On Error Resume Next

FinalRowGL = Cells(Rows.Count, 3).End(xlUp).Row


Range("C6:C" & FinalRowGL).Copy Destination:=Sheets("Lookups").Range("Y1")
Sheets("Lookups").Range("Y1").CurrentRegion.RemoveDuplicates Columns:=Array(1), Header:=xlYes

'Create folder
FolderName = ThisWorkbook.Path & "\" & "Print_PDF"
'FolderName = "D:\Dropbox\RutgersWPF\REPORTS_2021\Print_2021\Print_PDF"
MkDir FolderName

'==== Create files


For Each MyCell In Range("File_Names")
Sheets("Voucher").Range("J1").Value = MyCell.Value
Sheets("Lookups").Range("AA2").Value = MyCell.Value
'Sheets(Array("filters", "MOVEMENT", ReconSheet)).Copy
Sheets("Voucher").Copy
Set Destwb = ActiveWorkbook
Destwb.Sheets("Voucher").Activate
Call BreakLinks
FileName = ThisWorkbook.Sheets("Lookups").Range("AB2").Value
'Destwb.Sheets("Voucher").ExportAsFixedFormat Type:=xlTypePDF, FileName:= _
FolderName & "\" & FileName, Quality:=xlQualityStandard, IncludeDocProperties:=True, _
IgnorePrintAreas:=False, OpenAfterPublish:=False
Destwb.Sheets("Voucher").ExportAsFixedFormat Type:=xlTypePDF, FileName:=FolderName & "\" & FileName
Destwb.Close SaveChanges:=False
ThisWorkbook.Activate
Next MyCell

'Sheets("Voucher").Visible = False
Application.DisplayAlerts = True
Application.EnableEvents = True
Application.ScreenUpdating = True
End If

End Sub

Sub add_all_to_payments()

Dim FinalRowPaymentsData1 As Integer


Dim FinalRowPaymentsData2 As Integer

On Error Resume Next

If Range("F4").Value = "(All)" And Range("B4").Value = 0 _


And Sheets("Payments_Today").Range("B1").Value = 1 _
And Sheets("Payments_Today").Range("C1").Value = 1 Then

Application.ScreenUpdating = False

Call clear_payments
Sheets("GL").Range("A6").CurrentRegion.AdvancedFilter Action:=xlFilterCopy, _
CriteriaRange:=Sheets("Criteria").Range("E4:E5"), _
CopyToRange:=Sheets("_payments").Range("A3:E3"), _
Unique:=True
Sheets("Payments").Cells.FormatConditions.Delete
FinalRowPaymentsData1 = Sheets("_payments").Cells(Rows.Count, 1).End(xlUp).Row
If FinalRowPaymentsData1 > 3 Then
Sheets("_payments").Range("F1:V1").Copy
Sheets("_payments").Range("F4:V" & FinalRowPaymentsData1).PasteSpecial Paste:=xlPasteAll, SkipBlanks:=True
FinalRowPaymentsData2 = FinalRowPaymentsData1 - 3
Sheets("_formats").Range("A2:N2").Copy
Sheets("Payments").Range("A1:N" & FinalRowPaymentsData2).PasteSpecial Paste:=xlPasteFormats
Sheets("_payments").Range("I4:V" & FinalRowPaymentsData1).Copy
Sheets("Payments").Range("A1").PasteSpecial Paste:=xlPasteValues
End If

Sheets("Payments").Select

Application.CutCopyMode = False
Application.ScreenUpdating = True
End If

End Sub

Sub clear_payments()

Sheets("_payments").Rows("4:10000").Clear
Sheets("Payments").Cells.Clear
Sheets("Lookups").Range("Y2:Y10000").ClearContents
Sheets("Payments").Cells.FormatConditions.Delete

End Sub

Sub clear_payments_today()

Range("E7:L106").ClearContents
Range("G7:I106").FormatConditions.Delete
Range("E7").Select

End Sub

Sub Save_As_CSV_File()

If ActiveSheet.Name = "Payments" Then


Application.DisplayAlerts = False

On Error Resume Next


Dim fileSaveName As Variant

cThisWorkbookPath = ThisWorkbook.Path
cTanggal = Sheets("GL").Range("M2").Value

FinalRowPaymentsData = Cells(Rows.Count, 1).End(xlUp).Row


Rows(FinalRowPaymentsData + 1 & ":100000").Delete
Sheets("Payments").Copy

ActiveWorkbook.SaveAs cThisWorkbookPath & "\" & "Bulk Payment " & cTanggal, FileFormat:=xlOpenXMLWorkbook
cPaymentFile = ActiveWorkbook
fileSaveName = Application.GetSaveAsFilename(InitialFileName:=cThisWorkbookPath & "\Bulk Payment " & cTanggal, _
fileFilter:="CSV Files (*.csv), *.csv")
If fileSaveName <> False Then
With ActiveWorkbook
.SaveAs FileName:=fileSaveName, FileFormat:=xlCSV, CreateBackup:=False, Local:=True
.Close False
End With
End If
cPaymentFile.Close False
Sheets("GL").Select

Application.DisplayAlerts = True
End If

End Sub

Sub Delete_Names()

On Error Resume Next


For Each ws In ActiveWorkbook.Worksheets
ws.Names("_FilterDatabase").Delete
ws.Names("Criteria").Delete
ws.Names("Extract").Delete
Next
On Error GoTo 0
End Sub

Sub BreakLinks()

Dim wb As Workbook
Set wb = Application.ActiveWorkbook
If Not IsEmpty(wb.LinkSources(xlExcelLinks)) Then
For Each link In wb.LinkSources(xlExcelLinks)
wb.BreakLink link, xlLinkTypeExcelLinks
Next link
End If

End Sub

Sub print_voucher() ' not used anymore


If Range("F4").Value <> "(All)" And Range("M3").Value > 0 Then
Sheets("Voucher").Range("J1").FormulaR1C1 = "=GL!R[3]C[-4]"
'Sheets("Voucher").Visible = True
Sheets("Voucher").PrintPreview
'Sheets("Voucher").PrintOut
'Sheets("Voucher").Visible = False
Sheets("GL").Select
End If
End Sub

You might also like