Can someone please assist with writing this formula in VBA:
=IF(RIGHT(TEXT(C2,"mm/dd/yy hh:mm:ss"),2)>"30",LEFT(C2,14)+0.000694,C2)
This is what I have so far, but I am receiving a type mismatch error. Please be aware this is a test Sub that I am using via a command button on a sheet. Ultimately this will be transfered into Outlook to pull date/time appropriately.
=IF(RIGHT(TEXT(C2,"mm/dd/yy hh:mm:ss"),2)>"30",LEFT(C2,14)+0.000694,C2)
This is what I have so far, but I am receiving a type mismatch error. Please be aware this is a test Sub that I am using via a command button on a sheet. Ultimately this will be transfered into Outlook to pull date/time appropriately.
Code:
Private Sub CommandButton1_Click()
'=IF(RIGHT(TEXT(C2,"mm/dd/yy hh:mm:ss"),2)>"30",LEFT(C2,14)+0.000694,C2)
If Right(Format(ActiveCell.Offset(0, -4).Value, "mm/dd/yy hh:mm:ss"), 2) > "30" Then
ActiveCell.Value = (Left(ActiveCell.Offset(0, -4).Value, 14) + 0.000694)
Else
ActiveCell.Value = Left(ActiveCell.Offset(0, -4).Value, 14)
End If
End Sub