PDA

View Full Version : Need help to Code VBA using the combination of text and date format



Bingo5241
06-18-2020, 11:01 PM
Hi guys! Can you please help to write simple code in VBA so it will contain the following (in Excel in one line combine text and current date). Example: in Excel i expect to see the following =IF(A28="","","Processed(current date)")
I have this below written in VBA:
sFormula4 = "=IF(A27=" & Chr(34) & "" & Chr(34) & "," & Chr(34) & "" & Chr(34) & "," & Chr(34) & "Processed" & Chr(34) & ")"

My question: how to write code so it will add current date after word Processed? Format mmddyyyy, so it will look like Processed06182020.

Thanks

SamT
06-19-2020, 09:09 AM
If CBool(InStr(Range("A27"), "Processed")) Then
X = "Processed" & Format(Date, "mmddyyyy")
End If

Note: If you ever intend to sort by Processed Date, I recommend Format = "yyyymmdd".

Bingo5241
06-19-2020, 10:35 AM
Thank you !