View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Mike Fogleman Mike Fogleman is offline
external usenet poster
 
Posts: 1,092
Default Not sure what to name this subject

You should set the value for N before using it in a statement
N=1
Set MYSHEET&N = Workbooks("Group "&N".xls").Sheets("SheetName").

Will interpret as: MYSHEET1 = Workbooks(Group1.xls).Sheets("SheetName")
Notice the space between Group and 1 and using N outside of quotes.
Mike F


"MARTY" wrote in message
...
Hello:

If N is an integer, is the following syntax (&N) allowed
in workbook names, objects, etc?

Example: If I write this:

Set MYSHEET&N = Workbooks(Group&N.xls).Sheets
("SheetName").

and then I set N = 1, will VBA interpret this as:

Set MYSHEET1 = Workbooks(Group1.xls).Sheets("SheetName")

? If not (i.e., it doesn't like that), does anyone know
the correct syntax for something like this? Would I have
to use "..." anywhere in order for it to be correct?

Thanks,
MARTY