Dear Experts
I have code to pull data from closed wbs of depends upon column header values.. I need to make edit on code like to pull data from particular wb not from all wbooks...
find the code
Sub CCIBRINGING()
Dim strFolderPath As String
Dim strFile As String
Dim wbNew As Workbook
Dim wsTarg As Worksheet
Dim CalcMode As Long
Dim lngLastRow As Long
Dim lngTargRow As Long
Dim rng As Range
Dim rngCell As Range
Dim rngFound As Range
Dim strAddr As String
Dim rngDouble As Range
Const cstrEXT_XL As String = "*.xlsb"
Const cstrSEARCH As String = "A1:AC1"
With Application ' Set various application properties.
CalcMode = .Calculation
.Calculation = xlCalculationManual
.ScreenUpdating = False
.AskToUpdateLinks = False
.EnableEvents = False
.DisplayAlerts = False
End With
Set wsTarg = ThisWorkbook.Sheets("TODAY") 'Imports the data into the activesheet. Change to suit
wsTarg.Range("A2:AF" & Rows.Count).ClearContents
'Initialise the following varibales to the first *.xls file in the designated folder
strFolderPath = "C:\Users\aruna\Desktop\Aio\" 'Change to your own path
If Right(strFolderPath, 1) <> "\" Then ' Add a slash at the end of the path if needed.
strFolderPath = strFolderPath & "\"
End If
strFile = Dir(strFolderPath & cstrEXT_XL) 'Excel file types to import due to Constant
Do Until strFile = ""
lngTargRow = wsTarg.Cells.Find("*", , , , xlByRows, xlPrevious).Row + 1
Set wbNew = Workbooks.Open(strFolderPath & strFile)
Set rng = wbNew.Worksheets("Sheet1").Range("A1:DD1")
lngLastRow = wbNew.Worksheets("Sheet1").Cells.Find("*", , , , xlByRows, xlPrevious).Row
For Each rngCell In wsTarg.Range(cstrSEARCH)
If WorksheetFunction.CountIf(wsTarg.Range("A1", rngCell), rngCell) = 1 Then
Set rngFound = rng.Find(rngCell, rng.Cells(rng.Cells.Count), xlValues, xlWhole)
If Not rngFound Is Nothing Then
wsTarg.Cells(lngTargRow, rngCell.Column).Resize(lngLastRow - 1, 1).Value = rngFound.Offset(1).Resize(lngLastRow - 1).Value
If WorksheetFunction.CountIf(wsTarg.Range("A1:AF1"), rngCell) > 1 Then
strAddr = rngCell.Address
Set rngDouble = rngCell
Do
Set rngDouble = wsTarg.Range(cstrSEARCH).FindNext(After:=rngDouble)
If Not rngDouble Is Nothing Then
Set rngFound = Cells.FindNext(After:=rngFound)
wsTarg.Cells(lngTargRow, rngDouble.Column).Resize(lngLastRow - 1, 1).Value = rngFound.Offset(1).Resize(lngLastRow - 1).Value
End If
Loop While rngDouble.Address <> strAddr
strAddr = ""
End If
End If
End If
Next rngCell
wsTarg.Cells(lngTargRow, "AF").Resize(lngLastRow - 1) = strFile
wbNew.Close savechanges:=False
strFile = Dir()
Loop
With Application
.ScreenUpdating = True
.EnableEvents = True
.Calculation = CalcMode
.AskToUpdateLinks = True
.DisplayAlerts = True
End With
MsgBox "Files have now been imported."
End Sub
Find the attachment of Pull is with code and master wb of data pulling...
I saved two files today & Yesterday in folder,but i want pull data only from today wb
Bookmarks