Sub usematch () DIM S_P AS STRING, E_P As String Dim Num as INTEGER NUM = 0 for Each M in Range ("A: A") IF M.Value <> "" "" "THEN NUM = Num 1 Else EXIT for End IF Next M ERANGE = "B" & num ERANGE = "B2:" & Erange n = 1 a = 2 CURRANGE = "B" & a cells.select selection.sort key1: = range ("a2"), Order1: = xlascending , Key2: = Range ( "B2") _, Order2: = xlAscending, Header: = xlGuess, OrderCustom: = 1, MatchCase: = _ False, Orientation: = xlTopToBottom, SortMethod: = xlPinYin, DataOption1: = _ xlSortNormal, DataOption2 : = XlsortNormal Column ("A: A"). Select Selection.Insert Shift: = XLtoright 'The left inserts a column set curcell = worksheets (Sheets (1) .name) .Range (CURRANGE) for Each M in Range On Error Goto Errorhandler if M.Offset (0, -1) .Value <> "" "" "The Goto MyNext 'The current cell left is not empty / right The cell content is empty, S_P = M.Value: E_P = m.offset (0, 1) .value Pos = Application.Worksheet Function.match (E_P, Worksheets (1) .Range (Ereg), 0) 'Find the number of rows that the end point appears at the starting point = "" "" The curcell.offset (0, -1) .Value = "no" goto MYNEXT 'Didn't find it to "no" end ifthenext: position = "b" & trim (STR (POS))' positioned .Offset (0, 1) .Value = s_p then If Range (Position) .offset (0, -1) = "" "Then" If the condition is eligible, mark curcell.offset (0, -1) .value = N & ".a"
Range (position) .offset (0, -1) .value = n & ".b" n = n 1 else curcell.offset (0, -1) .value = "no" end if else ifout (position) .Offset (1, 0) .Value = E_P THEN POS = POS 1 goto Thenext else curcell.offset (0, -1) .Value = "no" end if end ifvar = 0mYnext: a = a 1 currange = "B" & a set curcell = worksheets (Sheets (1) .name) .Range (CURRANGE) NEXTERRORHANDAL: CURCELL.OFFSET (0, -1) .Value = "no" resume nextend Sub
The form is: A column and B column. The matching condition is: According to the line query, if the first line A column cell content is equal to another line B column cell content, check whether the first line B column cell content is equal to another One line A column unit content, if you are equal, you can mark before these two lines. Otherwise marked as NO