combining data from data sheets..

  • Thread starter Thread starter psi
  • Start date Start date
P

psi

We have daily data sheets saved down as:


SERVER\folder\FEB\filename feb 28
SERVER\folder\MAR\filename mar 01
SERVER\folder\MAR\filename mar 02
etc..

I want to combine this data for the last 6months.
What is the easiest way to do that?

I'm guessing some kind of for/next loop?

I'm fairly new to vba so how do I:

- set the filename to load (either in vba or via a named cell in
"loading" sheet)
- copy/paste the data into the new "master file" in a way that doesn'
overlap

Your help guys/gals would be most appreciated..

Thanks
Si


(I could copy / paste but I can see me needing to do similiar again
and there are 100s of these to add...
 
Dim dt1 as Date
Dim dt as Date
dt1 = date - int(365/2)
dt = dt1
set sh = Thisworkbook.worksheets(1)
do while dt < date
set bk = workbooks.open(filename:="Server\folder\" & _
Ucase(Format(dt,"mmm")) & "\" & _
"filename " & format(dt,"mmm dd") & ".xls"
set rng = sh.Cells(rows.count,1).End(xlup)(2)
rng.value = dt
bk.Worksheets(1).UsedRange.copy _
Destination:=rng(2)
dt = dt + 1
Loop

The above code, while untested, you give you a general approach.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top