Attached show how the little AddPrefix function below can be used on a worksheet as well as part of another macro
Six is hard coded but you could easily make it an Optional parameter like 'Prefix' for flexibility
This goes on a Standard Module
Option Explicit
Function AddPrefix(X As Variant, Optional Prefix As String = "XXX-0000") As Variant
AddPrefix = X
If Len(CStr(X)) = 6 Then AddPrefix = Prefix & X
End Function
Sub UsedInMacro()
MsgBox AddPrefix("ABC")
MsgBox AddPrefix("ABCABC")
MsgBox AddPrefix("ABCABC", "ZZYYXX-WWVV")
MsgBox AddPrefix(123)
MsgBox AddPrefix(123456)
End Sub