Hi,
I'm trying to use the find function in VBA, but need the "what" to reference a variable rather than the actual search text. In this instance the variable is called "ModuleNo" which contains the name "M123456". VBA doesn't appear to be able to use the variable in this way. Any ideas?
This works:
Range("A1:Z500").Find(What:="M123456", LookIn:=xlValues).Select
This doesn't
Range("A1:Z500").Find(What:=ModuleNo, LookIn:=xlValues).Select
I'm trying to use the find function in VBA, but need the "what" to reference a variable rather than the actual search text. In this instance the variable is called "ModuleNo" which contains the name "M123456". VBA doesn't appear to be able to use the variable in this way. Any ideas?
This works:
Range("A1:Z500").Find(What:="M123456", LookIn:=xlValues).Select
This doesn't
Range("A1:Z500").Find(What:=ModuleNo, LookIn:=xlValues).Select