Hi
I'm building a macro where I want to use part of a string input by a user as the name of a named range. The user can put anything in the string - the strings are used as the column headers of the output of the macro.
As part of the macro I need to define a number of named ranges. I would like to use the strings entered by the user in the names - rather than generic numbering. I've manged to remove all the spaces from these strings using
varStr = Replace(userStr, " ", "")
But the user may use illegal naming characters in their string, an example of a string that is causing problems is:
Ref (ppm.m)
I would like to be able to just use all of the characters in the string before any illegal naming characters. So in the example above I would use the string "REF".
Is anyone able to advise me of an efficient method of achieving this? I'm developing the macro to work in Excel 2003.
Many thanks
I'm building a macro where I want to use part of a string input by a user as the name of a named range. The user can put anything in the string - the strings are used as the column headers of the output of the macro.
As part of the macro I need to define a number of named ranges. I would like to use the strings entered by the user in the names - rather than generic numbering. I've manged to remove all the spaces from these strings using
varStr = Replace(userStr, " ", "")
But the user may use illegal naming characters in their string, an example of a string that is causing problems is:
Ref (ppm.m)
I would like to be able to just use all of the characters in the string before any illegal naming characters. So in the example above I would use the string "REF".
Is anyone able to advise me of an efficient method of achieving this? I'm developing the macro to work in Excel 2003.
Many thanks