I have this code
I need two thing:
1- fixing problem clear the headers when using this line
should clear from row 2 not the headers
2- I need add procedure to merging numirc values in columns D,E based on column B (it means there are many dupliactes items in columnB should merging with summing values for column D,E.
VBA Code:
Option Explicit
Sub CopyRangeFromSetFolder()
Dim desWS As Worksheet, wb As Workbook, lRow As Long
Dim wbNm As String, Fld As String
Application.ScreenUpdating = False
Set desWS = ThisWorkbook.Sheets("Sheet1")
desWS.Range("A2").CurrentRegion.ClearContents
Fld = ThisWorkbook.Path & "\"
wbNm = Dir(Fld & "*.xls*", vbNormal)
Do While wbNm <> ""
If wbNm <> ThisWorkbook.Name Then
With GetObject(Fld & wbNm)
With .Sheets("MATCH")
lRow = .Cells.Find("*", SearchOrder:=xlByRows, SearchDirection:=xlPrevious).Row
.Range("A2:E" & lRow).Copy
desWS.Cells(desWS.Rows.Count, "A").End(xlUp).Offset(1).PasteSpecial xlPasteValues
End With
.Close False
End With
End If
wbNm = Dir()
Loop
Application.ScreenUpdating = True
End Sub
1- fixing problem clear the headers when using this line
VBA Code:
desWS.Range("A2").CurrentRegion.ClearContents
2- I need add procedure to merging numirc values in columns D,E based on column B (it means there are many dupliactes items in columnB should merging with summing values for column D,E.