Dear Experts
I have saved master workbook in particular folder with the range of A:AR columns .. i want pull values from master workbook into another workbook only desired column header through vba with two changes in H& AL columns,,
In the H:H column "CALL TYPE" in that where ever LABOR ONLY & LABOR & PART values change as "BRING IN"..
and In the AL:AL column "PRIORITY" in that entire row apply this formula
"IFERROR(IF(AND(AG2="A 0-2 Days",AI2="E 16-20 Days"),"1",IF(AND(AG2="A 0-2 Days",AI2="F 21-30 Days"),"1",IF(AND(AG2="A 0-2 Days",AI2="G >30 Days"),"1",IF(AND(AG2="B 3-5 Days",AI2="E 16-20 Days"),"1",IF(AND(AG2="B 3-5 Days",AI2="F 21-30 Days"),"1",IF(AND(AG2="B 3-5 Days",AI2="G >30 Days"),"1",IF(AG2="A 0-2 Days","3",IF(AG2="B 3-5 Days","2",IF(AG2="C 6-10 Days","1",IF(AG2="D 11-15 Days","1",IF(AG2="E 16-20 Days","1",IF(AG2="F 21-30 Days","1",IF(AG2="G >30 Days","1"," ")))))))))))))," ")"
find the attachment...Master & Qubic.xlsb
below code to pull data from masterfile stored in "strFolderPath"
Sub BRINGINCASES()
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("CCI-BRINGIN") 'Imports the data into the activesheet. Change to suit
wsTarg.Range("A2:bk" & Rows.Count).ClearContents
'Initialise the following varibales to the first *.xls file in the designated folder
strFolderPath = "C:\Users\mani\Desktop\MALLI\Oops" '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("OPENCALL").Range("A1:DD1")
lngLastRow = wbNew.Worksheets("OPENCALL").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:bk1"), 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, "AP").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
Bookmarks