Change all the Variant variables to Long variables and it will work as you intend.
It would also have been preferable to have added your further question to your earlier post rather than start a new one.
To add code tags, select Go Advanced select the code and use the # button.
It is advisable to use Option Explicit to start your modules as this forces you to declare variables and makes errors easier to spot. You can set the VBA editor options to do this automatically.
__________________
Graham Mayor - MS MVP (Word) (2002-2019)
Visit my web site for more programming tips and ready made processes www.gmayor.com
|