Consulting

Results 1 to 3 of 3

Thread: Need help to Code VBA using the combination of text and date format

  1. #1

    Need help to Code VBA using the combination of text and date format

    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

  2. #2
    Moderator VBAX Sage SamT's Avatar
    Joined
    Oct 2006
    Location
    Near Columbia
    Posts
    7,814
    Location
    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".
    I expect the student to do their homework and find all the errrors I leeve in.


    Please take the time to read the Forum FAQ

  3. #3
    Thank you !

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •