naming problem

  • Thread starter Thread starter chad
  • Start date Start date
C

chad

hi guys
I'm new to all this and i need a little help.Im using 2
files and getting data from one and putting it into the
other main one ie using a general one and a specific
one.is there any way i can assign a quick reference at
the begining of the macro.i guess it will be like:

dim wrkbook1 as SOMETHING
dim wrkbook2 as SOMETHING

if X = NEWYORK then
wrkbook1 = "f:/gen.xls"
wrkbook2 = "f:/newyorkdata.xls"
else
if X = LA then
wrkbook1 = "f:/gen.xls"
wrkbook2 = "f:/ladata.xls"
end if

then i can use things like:

Windows(wrkbook1).Activate

or:

wrkbook1.Sheets(1).Move Before:=wrkbook2.Sheets(1)

i have tried a few times to do this but none of them work
out.

Thanks to anyone who can help.

C. Solomon
 
Hi
try something like

Sub foo()
Dim wbk1 As Workbook
Dim wbk2 As Workbook
Set wbk1 = ActiveWorkbook
Workbooks.Open "D:\temp\mappe2.xls"
Set wbk2 = Workbooks("mappe2.xls")
wbk1.Activate
End Sub
 
Back
Top