gauravkrgautam
Member
Hi All,
i need little help in getting my code work properly. my codes are below what i want to do is i have folder(dir) named as "DAR" where are 150 workbooks but there are 30 workbooks with .xlsm format type and i am trying to compile them. but on running code first file (alphabetically first file with .xlsm file) is collating every time and code is going infinity.
here is the code :
[pre]
[/pre]
i need little help in getting my code work properly. my codes are below what i want to do is i have folder(dir) named as "DAR" where are 150 workbooks but there are 30 workbooks with .xlsm format type and i am trying to compile them. but on running code first file (alphabetically first file with .xlsm file) is collating every time and code is going infinity.
here is the code :
[pre]
Code:
'=======================================================
Sub test()
Dim mwb As Workbook 'master workbook
Dim rfa As String 'resource folder address
Dim rfn As String 'resource file name
Dim fan As String 'file address and name
Dim nbr As Integer 'next to bottom row
Set mwb = ThisWorkbook
rfa = "C:Documents and SettingsuserDesktopantivirus ReportExternal ReportDAR"
'MsgBox rfa
rfn = Dir(rfa & "*.xlsm")
'MsgBox rfn
fan = rfa & rfn
'MsgBox fan
'Do While Len(rfn) > 0
Workbooks.Open (fan)
Workbooks(rfn).Sheets("backup").Range("a3:cz65000").Select
Selection.Copy
mwb.Activate
nbr = mwb.Sheets("sheet2").Range("b100000").End(xlUp).Row + 1
Sheets("sheet2").Range("b" & nbr).Select
With Selection
.PasteSpecial xlPasteValues
.PasteSpecial xlPasteColumnWidths
.PasteSpecial xlPasteFormats
.CurrentRegion.Font.Size = 9
End With
Workbooks(rfn).Activate
Workbooks(rfn).Close False
'rfn = Dir
'Loop
End Sub