This VBA code loops through rows in two worksheets, compares values in columns A and D, and if they match copies a value from column L in the first worksheet to column K in the second worksheet, and writes "Adjusted" in column L of the first worksheet. It sets two workbooks and worksheets, loops through rows comparing values, and copies/writes values if a match is found.
This VBA code loops through rows in two worksheets, compares values in columns A and D, and if they match copies a value from column L in the first worksheet to column K in the second worksheet, and writes "Adjusted" in column L of the first worksheet. It sets two workbooks and worksheets, loops through rows comparing values, and copies/writes values if a match is found.
This VBA code loops through rows in two worksheets, compares values in columns A and D, and if they match copies a value from column L in the first worksheet to column K in the second worksheet, and writes "Adjusted" in column L of the first worksheet. It sets two workbooks and worksheets, loops through rows comparing values, and copies/writes values if a match is found.
This VBA code loops through rows in two worksheets, compares values in columns A and D, and if they match copies a value from column L in the first worksheet to column K in the second worksheet, and writes "Adjusted" in column L of the first worksheet. It sets two workbooks and worksheets, loops through rows comparing values, and copies/writes values if a match is found.
Set wb1 = ThisWorkbook ' set the first workbook as the active workbook Set ws1 = wb1.Sheets("Sheet6") ' set the first worksheet
' open the second workbook
Set wb2 = Workbooks.Open("E:\MyData\2022-23\ADJUSTED CHALLAN\adjusted.xlsx") Set ws2 = wb2.Sheets("Sheet1") ' set the second worksheet
' loop through the rows in the first worksheet
For i = 1 To ws1.Range("A" & Rows.Count).End(xlUp).Row ' loop through the rows in the second worksheet For j = 1 To ws2.Range("A" & Rows.Count).End(xlUp).Row ' check if the value in column A of the first worksheet matches the value in column A of the second worksheet ' and if the value in column D of the first worksheet matches the value in column D of the second worksheet If ws1.Cells(i, 1).Value = ws2.Cells(j, 1).Value And ws1.Cells(i, 4).Value = ws2.Cells(j, 4).Value Then ' if the values match, copy the value from column L of the first worksheet to column K of the second worksheet ws2.Cells(j, 11).Value = ws1.Cells(i, 12).Value ' write "Adjusted" in column L of the first worksheet ws1.Cells(i, 12).Value = "Adjusted" End If Next j Next i