Private Sub CommandButton1_Click()
Dim exist As Boolean
Dim wName As String
Dim sh As Worksheet
Dim wRow As Double, uRow As Double
Application.ScreenUpdating = False
'Validations
If txtDirectMonth.Value = "" Then
MsgBox "Enter Month"
txtDirectMonth.Select
Exit Sub
End If
If txtDirectYear.Value = "" Then
MsgBox "Enter Year"
txtDirectYear.Select
Exit Sub
End If
exist = False
wName = LCase(txtDirectMonth.Value) & " " & LCase(txtDirectYear.Value)
For Each sh In Sheets
If LCase(sh.Name) = wName Then
exist = True
Exit For
End If
Next
If exist = False Then
MsgBox "The sheet : " & wName & " does not exist", vbCritical
Else
wRow = ActiveCell.Row
uRow = Sheets(wName).Range("A" & Rows.Count).End(xlUp).Row + 1
Range(Cells(wRow, "A"), Cells(wRow, "J")).Copy
Sheets(wName).Range("A" & uRow).PasteSpecial xlValue
Range(Cells(wRow, "O"), Cells(wRow, "O")).Copy
Sheets(wName).Range("K" & uRow).PasteSpecial xlValue
Range(Cells(wRow, "AD"), Cells(wRow, "AF")).Copy
Sheets(wName).Range("N" & uRow).PasteSpecial xlValue
Sheets(wName).Range("L" & uRow).Formula = "=K" & uRow & " * 0.1"
Sheets(wName).Range("M" & uRow).Formula = "=L" & uRow & " + K" & uRow
'ActiveSheet.Rows(wRow).Copy
'Sheets(wName).Rows(uRow).PasteSpecial xlValue
ActiveSheet.Rows(wRow).Delete
End If
Application.ScreenUpdating = False
MsgBox "Transferred row"
End Sub