Sub SMS()
Dim a, b() As String, i As Long, ii As Long, n As Long, txt As String
Dim Last_Row1 As Long
Dim Find1 As String
Dim k1 As String
Dim Find2 As String
Dim k2 As String
Dim Find3 As String
Dim k3 As String
Dim Find4 As String
Dim k4 As String
Dim Find5 As String
Dim k5 As String
Dim Find6 As String
Dim k6 As String
Dim Rng As Range
With Sheets("salaries")
With .Range("a1", .Cells.SpecialCells(11))
a = Application.Index(.Value, Evaluate("row(1:" & .Rows.Count & ")"), _
Array(1, 2, 6, 9, 10, 11, 12, 13, 14, 15, 16, 17, 19, 24, 25, 26, 27))
End With
End With
ReDim b(1 To UBound(a, 1))
For i = 4 To UBound(a, 1)
If a(i, 1) Like "*.*" Then
n = n + 1
txt = Join(Array(a(i, 2), a(i, 3)), ",") & ","
txt = txt & Split(a(i, 1), ".")(1) & " your salary for " & _
LCase$(Format$(Date, "mmm.yy")) & " is Basic " & a(i, 4)
For ii = 5 To UBound(a, 2)
If a(i, ii) <> "" Then txt = txt & " " & a(3, ii) & " " & a(i, ii)
Next
b(n) = txt
End If
Next
If n > 0 Then
ReDim Preserve b(1 To n)
Open ThisWorkbook.Path & "\SMS_Salaries.csv" For Output As #1
Print #1, Join(b, vbCrLf)
Close #1
End If
' Reopen CSV for Modification "" in Start end C column and Negative for Deductions
Workbooks.Open ThisWorkbook.Path & "\SMS_Salaries.csv"
Find1 = "TAX 0"
k1 = ""
Columns("C").Replace what:=Find1, replacement:=k1, lookat:=xlPart, MatchCase:=False
Find2 = "Pension 0"
k2 = ""
Columns("C").Replace what:=Find2, replacement:=k2, lookat:=xlPart, MatchCase:=False
Find3 = "ADV. 0"
k3 = ""
Columns("C").Replace what:=Find3, replacement:=k3, lookat:=xlPart, MatchCase:=False
Find4 = "Sacco 0"
k4 = ""
Columns("C").Replace what:=Find4, replacement:=k4, lookat:=xlPart, MatchCase:=False
Find5 = "ABS. 0"
k5 = ""
Columns("C").Replace what:=Find5, replacement:=k5, lookat:=xlPart, MatchCase:=False
Find6 = "ABS. 0"
k6 = ""
Columns("C").Replace what:=Find6, replacement:=k6, lookat:=xlPart, MatchCase:=False
Set Rng = Range("C1:C" & Cells(Rows.Count, "A").End(xlUp).Row)
With Rng.Offset(, 2)
.Formula = "=" & String(4, Chr(34)) & "&C1&" & String(4, Chr(34))
.Value = .Value
End With
Range("E:E").Copy Range("C:C")
Columns("D:E").Delete
Range("A1:A10000").Select
Selection.NumberFormat = "0"
ActiveWorkbook.Save
ActiveWorkbook.Close
End Sub