Check & Update existing rows of data to fill in the blanks

Kemidan2014

Board Regular
Joined
Apr 4, 2022
Messages
229
Office Version
  1. 365
Platform
  1. Windows
To the Credit of DanteAmor who helped me with this code I thought i would start a new thread since my original problem was solved but i need to expand on this
Below is the WORKING code that automates a task i need to do which is Pull from a designated file that we download from customers website and name it the same name every time
This macro does its job and finds the new records and adds them to the bottom of our Master complaint Tracking spreadsheet which is a separate workbook that contains all the macros.

I tested if it would find newly added Dates in one of the columns for records that had been existing and failed to pick them up OR if the STATUS changed in one of the columns it would not recognized this

how could we expand on this so that it looks at the older records to see if there are changes to them and updates the data in the destination worksheet?

VBA Code:
Sub Filter_Data()
  Dim lr As Long
  Dim srcSH As Worksheet, desSH As Worksheet
 
  Application.ScreenUpdating = False
  Workbooks.Open ("O:\1_All Customers\Current Complaints\ToyotaData.xlsx")
  Set srcSH = ActiveWorkbook.Sheets("Data")
  Set desSH = Workbooks("Customer Database Test 2.xlsm").Worksheets("sheet1")
 
  With srcSH
    If .AutoFilterMode Then .AutoFilterMode = False
    lr = .Range("A" & Rows.count).End(3).Row
    .Range("AN2:AN" & lr).Formula = "=IFERROR(IF(MATCH(A2,'[" & desSH.Parent.Name & "]" & desSH.Name & "'!$A:$A,0),""true"",""false""),""false"")"
    .Cells(1).CurrentRegion.AutoFilter 40, "false"
    If srcSH.Range("A" & Rows.count).End(3).Row > 1 Then
      .Range("A2:B" & lr & ",D2:E" & lr & ",H2:K" & lr & ",O2:O" & lr & ",Q2:AB" & lr & ",AH2:AH" & lr).SpecialCells(xlCellTypeVisible).Copy
      desSH.Cells(.Rows.count, "A").End(xlUp).Offset(1).PasteSpecial Paste:=xlPasteValues
      desSH.Columns.AutoFit
    End If
    .Range("A1").AutoFilter
    .Columns("AN").ClearContents
  End With
  srcSH.Parent.Close False
  Application.ScreenUpdating = True
End Sub

SOURCE SHEET
ToyotaData2.xlsx
ABCDEFGHIJKLMNOPQRSTUVWXYZAAABACADAEAFAGAHAIAJAKALAM
1QIMS#Doc TypeInstance Handle KeyRankSupplier CodeTMMC Supplier CodeSupplier NamePart NamePart NumberOverall StatusNCD DescriptionQENameFull NameFull NameModelSQA RankLT CM Plan DueOriginal LTCM Actual Due DateRevised LTCM Actual Due DateCloseInitial Issuance DateOfficial Issuance DateLTCM Plan SubmittedLTCM Plan Accepted DateLTCM Plan Rejection DateLTCM Actual SubmittedLTCM Actual Accepted DateLTCMActualRejectionDateOccurenceWhere NC found?Will Parts Be Quarantined ?Why Made CategoryWhy Shipped CategoryNAMCST/CM StatusLT/CM StatusStandardActualAssigned To
201-01016-V6-1111QPRIrrelevent DataB0101-6Aisin Automotive Casting - TennesseePart 111111Closed-CancelledFIT CONDITIONQEAMMGRV65/3/20214/28/2021First TimeGR-KAIfalseCUST 1STCM ReceivedGASKET HAS TO BE SEATED ALL THE WAY AROUND, CANNOT BE STICKING UPHEAD COVER GASKET NOT SEATED205519
301-01016-V6-2222QPRIrrelevent DataB0101-6Aisin Automotive Casting - TennesseePart 222222Awaiting Official, STCM ApprovedLOOSEQEAMMGRV65/3/20214/28/2021First TimeGR-KAIfalseCUST 1STCM ReceivedGASKET MUST STAY IN PLACEGASKET OUT OF GROOVE205519
401-01016-V6-3333QPRIrrelevent DataC0101-6Aisin Automotive Casting - TennesseePart 211111Officially Released, Awaiting LTCM PlanPOPPING / PULLING OUTQEAMMGRV65/3/20214/28/2021First TimeGR-KAItrueCUST 1STCM ReceivedGASKET TO BE SEATED AND NOT "OUT" OF THE GASKET GROOVEGASKET IS NOT SEATED WHEN CONVEYANCE IS LOADING THE PART205519
501-01016-V6-4444QPRIrrelevent DataB0101-6Aisin Automotive Casting - TennesseePart 333333Officially Released, Awaiting LTCM PlanWRONG PARTQEAMMGRV63/8/20223/7/2022First TimeNONCtrueCUST 1Awaiting STCMCorrect bolt with 8 markingWrong bolt with no 8 marking205519
60101-6-080-5555QPRIrrelevent DataB0101-6Aisin Automotive Casting - TennesseePart 333333Officially Released, Awaiting LTCM PlanSCRATCHESQEAMMGRI49/25/20179/15/2016RecurrenceAR Upper LinetrueCUST 2Parts must meet all specs.Part had scratch on seal surface.
Data


DESTINATION SHEET BEFORE UPDATE
Customer database test 2.xlsm
ABCDEFGHIJKLMNOPQRSTUV
1QIMS#Doc TypeRankSupplier CodePart NamePart NumberOverall StatusNCD DescriptionModelLT CM Plan DueOriginal LTCM Actual Due DateRevised LTCM Actual Due DateCloseInitial Issuance DateOfficial Issuance DateLTCM Plan SubmittedLTCM Plan Accepted DateLTCM Plan Rejection DateLTCM Actual SubmittedLTCM Actual Accepted DateLTCMActualRejectionDateNAMC
201-01016-V6-1111QPRB0101-6Part 111111Officially Released, Awaiting LTCM PlanFIT CONDITIONV64/28/20214/29/2021CUST 1
301-01016-V6-2222QPRB0101-6Part 222222Awaiting Official, STCM ApprovedLOOSEV65/3/20214/28/20214/29/2021CUST 1
401-01016-V6-3333QPRC0101-6Part 211111Officially Released, Awaiting LTCM PlanPOPPING / PULLING OUTV65/3/20214/28/20214/29/2021CUST 1
501-01016-V6-4444QPRB0101-6Part 333333Officially Released, Awaiting LTCM PlanWRONG PARTV63/8/20223/7/20223/7/2022CUST 1
Sheet1


DESTINATION SHEET AFTER UPDATE
Customer database test 2.xlsm
EFGHIJKLMNOPQRSTUV
1Part NamePart NumberOverall StatusNCD DescriptionModelLT CM Plan DueOriginal LTCM Actual Due DateRevised LTCM Actual Due DateCloseInitial Issuance DateOfficial Issuance DateLTCM Plan SubmittedLTCM Plan Accepted DateLTCM Plan Rejection DateLTCM Actual SubmittedLTCM Actual Accepted DateLTCMActualRejectionDateNAMC
2Part 111111Closed - CancelledFIT CONDITIONV65/3/20214/28/20214/29/2021CUST 1
3Part 222222Awaiting Official, STCM ApprovedLOOSEV65/3/20214/28/20214/29/2021CUST 1
4Part 211111Officially Released, Awaiting LTCM PlanPOPPING / PULLING OUTV65/3/20214/28/20214/29/2021CUST 1
5Part 333333Officially Released, Awaiting LTCM PlanWRONG PARTV63/8/20223/7/20223/7/2022CUST 1
6Part 333333Officially Released, Awaiting LTCM PlanSCRATCHESI44/1/20224/2/2022CUST 2
Sheet1


As you can see from the previous code its pulling SPECIFIC columns and you can see the complaint in row 1 became closed and cancelled and a data was added so Reitterationg the code will add the new record at the buttom but how to get it to update changed information to existing data???
 

Excel Facts

How to total the visible cells?
From the first blank cell below a filtered data set, press Alt+=. Instead of SUM, you will get SUBTOTAL(9,)
Solved

VBA Code:
Sub Update_trial_3()
  Dim srcSH As Worksheet, desSH As Worksheet
  Dim i As Long, j As Long, nRow As Long, n As Long
  Dim rng As Range, col As Range, c As Range, f As Range
  Workbooks.Open ("O:\1_All Customers\Current Complaints\ToyotaData.xlsx")
  Set srcSH = Workbooks("ToyotaData.xlsx").Sheets("Data")
  Set desSH = Workbooks("Customer Database Test 2.xlsm").Sheets("sheet1")
  Set rng = srcSH.Range("A:B,D:E,H:K,O:O,Q:AB,AH:AH")
 
  For Each c In srcSH.Range("A2", srcSH.Range("A" & Rows.count).End(3))
    Set f = desSH.Range("A:A").Find(c.Value, , xlValues, xlWhole, , , False)
    If Not f Is Nothing Then nRow = f.Row Else nRow = desSH.Range("A" & Rows.count).End(3).Row + 1
    j = 0
    For Each col In rng.Columns
      n = col.Column
      j = j + 1
      desSH.Cells(nRow, j).Value = srcSH.Cells(c.Row, n).Value
    Next
  Next
  srcSH.Parent.Close False
End Sub


Thanks Dante!
 
Upvote 0
Solution

Forum statistics

Threads
1,223,885
Messages
6,175,180
Members
452,615
Latest member
bogeys2birdies

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