Hi all
I have this following code, I want to add rounding to 2 decimals to this code:
full code is below:
I have this following code, I want to add rounding to 2 decimals to this code:
VBA Code:
'Net amount
Sheet1.Cells(rr, 8) = sh.Cells(k, 12)
'VAT amount
Sheet1.Cells(rr, 10) = sh.Cells(k, 9)
full code is below:
VBA Code:
Sub EXPENSE_JOURNAL_FOLDER()
Application.DisplayAlerts = False
d = GetFolderName()
d = d & "\"
Count = 0
Application.DisplayAlerts = False
sfile = Dir(d & "*.xls*")
rr = Sheet1.Cells(Sheet1.Rows.Count, 1).End(xlUp).Row + 2
Do While sfile <> ""
Set wb = Workbooks.Open(d & sfile)
'Set wb = ActiveWorkbook
Set sh = wb.Sheets(1)
n1 = 10
For n = 10 To 200
If sh.Cells(n, 1) = "TOTAL CLAIM" Then
n2 = n - 3
Exit For
End If
Next n
For n = n2 To n2 + 200
If sh.Cells(n, 1) = "Date" Then
m1 = n + 1
Exit For
End If
Next n
For n = m1 To m1 + 200
If sh.Cells(n, 1) = "TOTAL MILEAGE" Then
m2 = n - 3
Exit For
End If
Next n
nm = sh.Range("B3")
fn = Split(nm, " ")
fn1 = Left(fn(0), 1)
fn2 = Left(fn(1), 1)
fname = "EXP" & fn1 & fn2 & Format(Sheet1.Range("G2"), "ddmmyy")
For k = n1 To n2
If sh.Cells(k, 1) <> "" Then
'PI
Sheet1.Cells(rr, 1) = "PI"
Sheet1.Cells(rr, 2) = sh.Range("O4")
Sheet1.Cells(rr, 3) = sh.Cells(k, 15)
Sheet1.Cells(rr, 4) = sh.Cells(k, 16)
Sheet1.Cells(rr, 5) = Format(Sheet1.Range("G2"), "dd/mm/yyyy")
Sheet1.Cells(rr, 6) = fname
Sheet1.Cells(rr, 7) = sh.Cells(k, 3)
'Net amount
Sheet1.Cells(rr, 8) = sh.Cells(k, 10)
'VAT amount
Sheet1.Cells(rr, 10) = sh.Cells(k, 9)
Sheet1.Cells(rr, 9) = "T0"
If Sheet1.Cells(rr, 10) > 0 Then
Sheet1.Cells(rr, 9) = "T1"
End If
Sheet1.Cells(rr, 11) = 1
Sheet1.Cells(rr, 12) = "ISEXPORT:" & Format(Sheet1.Range("G2"), "dd/mm/yyyy")
rr = rr + 1
End If
Next k
'Mileage Form
For k = m1 To m2
If sh.Cells(k, 1) <> "" Then
'PI
Sheet1.Cells(rr, 1) = "PI"
Sheet1.Cells(rr, 2) = sh.Range("O4")
Sheet1.Cells(rr, 3) = sh.Cells(k, 15)
Sheet1.Cells(rr, 4) = sh.Cells(k, 16)
Sheet1.Cells(rr, 5) = Format(Sheet1.Range("G2"), "dd/mm/yyyy")
Sheet1.Cells(rr, 6) = fname
Sheet1.Cells(rr, 7) = sh.Cells(k, 3) & " to " & sh.Cells(k, 4)
'Net amount
Sheet1.Cells(rr, 8) = sh.Cells(k, 12)
'VAT amount
Sheet1.Cells(rr, 10) = sh.Cells(k, 9)
Sheet1.Cells(rr, 9) = "T0"
If Sheet1.Cells(rr, 10) > 0 Then
Sheet1.Cells(rr, 9) = "T1"
End If
Sheet1.Cells(rr, 11) = 1
Sheet1.Cells(rr, 12) = "ISEXPORT:" & Format(Sheet1.Range("G2"), "dd/mm/yyyy")
rr = rr + 1
End If
Next k
'rr = rr + 1
wb.Close
sfile = Dir
Count = Count + 1
Loop
Application.DisplayAlerts = True
MsgBox "Done . . . " & Count & " Files are Processed."
End Sub
Public Function GetFolderName(Optional OpenAt As String) As String
Dim lCount As Long
GetFolderName = vbNullString
With Application.FileDialog(msoFileDialogFolderPicker)
.InitialFileName = OpenAt
.Show
For lCount = 1 To .SelectedItems.Count
GetFolderName = .SelectedItems(lCount)
Next lCount
End With
End Function