loop

eran3185

Board Regular
Joined
Apr 28, 2007
Messages
142
hi

i have 30 files : *.xls

i want to do a loop that take the 1-200 lines from all the files , and put them in one file

how can i do this thing ?
 

Excel Facts

Difference between two dates
Secret function! Use =DATEDIF(A2,B2,"Y")&" years"&=DATEDIF(A2,B2,"YM")&" months"&=DATEDIF(A2,B2,"MD")&" days"
eran

Is the code in the link Stan posted no use?

If it is it might help if you told us how.:)
 
Upvote 0
first of all - i know very little about vba :confused:

i think that u and stan mean this part :
Sub teset()
Dim myDir As String, fn As String
myDir = "C:\test\" '<- change to suite
fn = Dir(myDir & "TM08e*.xls")
Do While fn <> ""
With Workbooks.Open(myDir & fn)
.Sheets("test suite").Copy
.Close False
End With
fn = Dir()
Loop
End Sub

but it wasnt good , i dont know what the meaning of "TM08e*.xls" , and what is all the variables
 
Upvote 0
eran3185,

What is the full path to where the workbooks are stored?

What is the sheetname that you want to copy from in all the workbooks?

What is the range, in the above sheetname, of the information you want to copy?

What is the workbook name, and sheetname, where you want to copy the information to?

Have a great day,
Stan
 
Upvote 0
What is the full path to where the workbooks are stored? c:/test

What is the sheetname that you want to copy from in all the workbooks? big is the summing workbook

What is the range, in the above sheetname, of the information you want to copy? a1:n100

What is the workbook name, and sheetname, where you want to copy the information to? i have some workbooks tat i want to copy to "big" , the name are : book1 , book2 , book3 .
the name of the sheetname is "7.07" in all of the workbooks

many many thanks
 
Upvote 0
stan , maybe u can explein me this ??
Sub teset()
Dim myDir As String, fn As String, a(), i As Integer, ws As Worksheet, LastR As Range
myDir = "C:\test\" '<- change to suite
fn = Dir(myDir & "TM08e*.xls")
Do While fn <> ""
With Workbooks.Open(myDir & fn)
.Sheets(1).Copy after:=ThisWorkbook.Sheets(1)
With ThisWorkbook.Sheets(1)
Set LastR = .Range("a40")
If Not IsEmpty(LastR) Then _
Set LastR = .Range("a" & Rows.Count).End(xlUp).Offset(1)
End With
With .Sheets(2).UsedRange
LastR.Resize(.Rows.Count, .Columns.Count).Value = .Value
End With
.Close False
End With
fn = Dir()
Loop
 
Upvote 0

Forum statistics

Threads
1,214,825
Messages
6,121,787
Members
449,049
Latest member
greyangel23

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top