View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Together[_7_] Together[_7_] is offline
external usenet poster
 
Posts: 1
Default Could we define series variables in one statement?

Hi, I am a new user of VBA in excel.

I want to know whether we can define a series variables in on
definition.

Such as:

Dim x(i) as integer

then, all the x(i), i=1,2,3.... is integer.

My situation is that I should copy several data in one file int
another file. If I copy the data one by one, it will take me a lo
time. Are there some methods that I can copy several data satisfyin
the condition to another file simulatenously.

my code is like these:

For i = 2 To 16

Workbooks.Open Filename:=DaSourceAfter & DaSourceFile 'open one file
Worksheets(1).Activate
totalvalue = Worksheets(1).Cells(i, 4).value
ActiveWorkbook.Close SaveChanges:=True

Workbooks.Open Filename:="D:\total\total.xls"
Worksheets(1).Activate
Worksheets(1).Cells(1, q) = DaSourceFile
Worksheets(1).Cells(p, q) = totalvalue

ActiveWorkbook.Close SaveChanges:=True
p = p + 1

Next i

Although I can copy the data to another file, it takes a lot time t
open and close the files. So I think that there should be some goo
method to improve the code. Could you tell me? Thanks

--
Message posted from http://www.ExcelForum.com