If you re ok with having pre-set sorts, one solution is to mirror both values from sheet A and sheet B to sheet C, and then just sort that, and re-populate the values in sheet A and B with the new, sorted, results.
页: 1
Sheet1 | Sheet 2 | Sheet 3 (Hidden and named)
| |
Name Age etc, | Eye Colour Hair colour etc. | =Sheet1!A1 ... =Sheet2!A1
Then your sort button would call a sub something like:
Dim rngSortRange As Range, rngStartCell As Range, rngEndCell As Range
Set rngStartCell = Worksheets("Sheet_3_Name_Goes_Here").Range("A1")
Set rngEndCell = Worksheets("Sheet_3_Name_Goes_Here").Range( _
rngStartCell.End(xlToRight).Column, _
rngStartCell.End(xlDown).Row)
Set rngSortRange = Worksheets("Sheet_3_Name_Goes_Here").Range(rngStartCell, rngEndCell)
rngSortRange.Sort Key1:=<Column Number Here>, Order1:=xlAscending, Header:=xlYes
rngSortRange.Range(rngStartCell, _
Worksheets("Sheet_3_Name_Goes_Here").Range( _
Worksheets("Sheet 1").Range("A1").End(xlToRight).Column, _
rngEndCell.Row _
) _
).Copy
Worksheets("Sheet 1").Paste
rngSortRange.Range(Worksheets("Sheet_3_Name_Goes_Here").Range(
rngStartCell.Column + Worksheets("Sheet 1").Range("A1").End(xlToRight).Column, _
rngStartCell.Row _
), _
rngEndCell _
).Copy
Worksheets("Sheet 2").Paste
这可能需要一些工作(例如,你可能需要事后重发3张,你可能需要重估,而不是仅仅过去,否则,你会破坏过去自我参照的模式),但基本想法应当发挥作用。