I have already posted the code you should use in this earlier reply in this thread.
2) If you specify a fixed value such as 36 or eileen as an argument to a procedure (sub) or function, the rules are:
- Number values can be entered as they are: Sqr(36)
- Text values (strings) must be enclosed in double quotes: UCase("eileen")
- (VBA and Access only) Dates must be enclosed in # characters: Year(#01/14/2023#)
This does not apply when you specify a variable, cell or field as argument:
Code: Select all
Sub Test()
Const MyNumber = 36
Const MyString = "eileen"
Const MyDate = #01/14/2023#
Debug.Print Sqr(MyNumber)
Debug.Print UCase(MyString)
Debug.Print Year(MyDate)
End Sub