OK, I've managed to get to a solution that almost works, using the MATCH worksheet function. The key bit of code that works is:
Dim LastMemRow As Integer
Dim FLAGFileRow As Integer
Dim FLAGFileNo As Integer
Dim MemNoRow As Integer
MemNoRow = WorksheetFunction.Match(FLAGFileNo, Workbooks(TalkRegTempFile).Worksheets("Setup Sheet").Range("A1", "A2000"), 0)
It looks for a match with the number FLAGFileNo in the other workbook, in cells A1-A2000 and returns the row number if a match is found, or 0 if not found. With that row number I can set the "X" flag in the relevant place.
The final bit I need to get working is to replace the "A2000" with a variable (LastMemRow) containing the last used row (I've got the code that sets this variable).
I've tried this code:
MemNoRow = WorksheetFunction.Match(FLAGFileNo, Workbooks(TalkRegTempFile).Worksheets("Setup Sheet").Range(Cells(1, 1), Cells(1, LastMemRow)), 0)
but although the FLAGFileNo and LastMemRow variables contain the correct results, the result MemNoRow is always 0
Maybe I can't use CELLS in this way in a function?
Bookmarks