- Joined
- Jul 27, 2007
- Messages
- 8
- Reaction score
- 0
In my macro I add sheets programatically based on values held in a variable.
e.g. Sheets.Add.Name = vCurrVendNos
vCurrVendNos is set to values in one of my sheets. I then copy and paste selected cells/ranges between my sheets. My variable is called vCurrVendNos an it has a value of "101030".
I am trying to do what this statement achieves. I used this simple statement to test whether it works and it does.
Sheets("101030").Select.
But the name of the sheets changes and I cannot hard code the value of all the sheets because it changes based on data within one of the sheets..
My problem is that when I use the following
Sheets(vCurrVendNos).Select
OR Sheets("vCurrVendNos").Select
OR Sheets("vCurrVendNos").Activate
I get my error routine being activated. I know this must be relatively simple but I can't seem to get the syntax or commands right.
e.g. Sheets.Add.Name = vCurrVendNos
vCurrVendNos is set to values in one of my sheets. I then copy and paste selected cells/ranges between my sheets. My variable is called vCurrVendNos an it has a value of "101030".
I am trying to do what this statement achieves. I used this simple statement to test whether it works and it does.
Sheets("101030").Select.
But the name of the sheets changes and I cannot hard code the value of all the sheets because it changes based on data within one of the sheets..
My problem is that when I use the following
Sheets(vCurrVendNos).Select
OR Sheets("vCurrVendNos").Select
OR Sheets("vCurrVendNos").Activate
I get my error routine being activated. I know this must be relatively simple but I can't seem to get the syntax or commands right.
Last edited: