Click here to Skip to main content
15,884,176 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am trying to concatenate a cell containing RC + Date + time in VB in excel but I am getting error that no sub or function has been defined.
I am new using macros

What I have tried:

VB
Private Sub Worksheet_change(ByVal Target As Range)
    If Not Application.Intersect(Target, Range("B:B")) Is Nothing Then
        Range("C" & Target.Row) = Format(Date, "DD.MM.YY")
        Range("D" & Target.Row) = Format(Date, "YYYY.MM")
        Range("F" & Target.Row) = Format(Now, "HHMMSS")
        Range("G" & Target.Row) = Format(Concatenate("RC", Format(Date, "DDMMYYY"), Format(Now, "HHMMSS")))
    End If
End Sub
Posted
Updated 23-Sep-22 20:43pm
v2

1 solution

If you are trying to use the Excel CONCATENATE function[^] here, then you can't - that is an "in cell" function, rather than a VB function.

So join strings, use the appropriate VB code directly - that will depend on the version of VB you are using: VB6, VB.NET, or VBA so Google for "concatenate strings" and the VB version and you should find what you need.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900