(Solved) – How to get the String value from the function as my code gets the compile error ‘Wrong number of arguments or invalid property assignment’

(solved)-–-how-to-get-the-string-value-from-the-function-as-my-code-gets-the-compile-error-‘wrong-number-of-arguments-or-invalid-property-assignment’

Below is my code to call the Function RandomBoysName to get the random name from the array of names in the function

Sub test()

Range("A1").Value = RandomBoysName

End Sub

Below is the function which returns the random boys name from the array.


Public Function RandomBoysName() As String

RandomBoysName = Array("Jacob", "Michael", "Joshua", "Matthew", "Christopher")

randArrIndex = Int((UCase(RandomBoysName)   1) * Rnd)

RandomBoysName = "TEST"

RandomBoysName = RandomBoysName & RandomBoysName(randArrIndex)

End Function

Getting the error Wrong number of arguments or invalid property assignment in the below line

randArrIndex = Int((UCase(RandomBoysName)   1) * Rnd)

Leave a Reply

Your email address will not be published. Required fields are marked *