Hello. I'm trying to build a macro that can find and match two sheets. In my workbook I have three sheets: MACRO (Where the buttons are located), FIL, and SHIPMENT. I already have a macro for FIL, where it finds the column header TOTAL and find its last cell, and copy that cell value to a specific cell in the MACRO sheet. Here comes the problem: I need to find the same value in the SHIPMENT sheet, and before it finds the value it needs to find the words "FIL WAGE SUMMARY" (Column H) before it finds the same value of the TOTAL in sheet FIL (Same row as FIL WAGE SUMMARY, Column P). It needs to be that way to avoid finding values that aren't in the same row as the FIL WAGE SUMMARY row. And after it finds the needed value in SHIPMENT sheet, it needs to be copied and placed in a specific cell in the MACRO sheet.
To sum up:
Using the cell value of TOTAL in sheet FIL, find the words "FIL WAGE SUMMARY" in column H and find the cell in column P that matches the value in sheet FIL (Same row), and place that duplicate value to a specific cell in MACRO sheet.
This is the code for the FIL sheet:
Any suggestions will be greatly appreciated. Thank you!
To sum up:
Using the cell value of TOTAL in sheet FIL, find the words "FIL WAGE SUMMARY" in column H and find the cell in column P that matches the value in sheet FIL (Same row), and place that duplicate value to a specific cell in MACRO sheet.
This is the code for the FIL sheet:
Code:
Dim headerRow As LongDim totalColumnsInHeaderRow As Long
Dim searchColumn As Long
Dim lastRowInSearchColumn As Long
Dim currentColumn As Long
Dim columnSearchString As String
With Sheets("FIL")
headerRow = 9
totalColumnsInHeaderRow = .Cells(headerRow, Columns.Count).End(xlToLeft).Column
columnSearchString = "TOTAL"
searchColumn = 0
For currentColumn = 1 To totalColumnsInHeaderRow
If StrComp(.Cells(headerRow, currentColumn).value, columnSearchString, vbTextCompare) = 0 Then
searchColumn = currentColumn
Exit For
End If
Next currentColumn
If searchColumn > 0 Then
lastRowInSearchColumn = .Cells(Rows.Count, searchColumn).End(xlUp).Row
Sheets("MACRO").Range("B2") = _
.Cells(lastRowInSearchColumn, searchColumn).value
End If
End With
Any suggestions will be greatly appreciated. Thank you!