Sub buttonClick()
Call otherSheetSerch(ThisWorkbook.Worksheets("合同管理"), ThisWorkbook.Worksheets("Sheet1"), 2, 2, 1, 1, 2, 2)
End Sub
'不同表间关联查找:表workSheet1的keyColumn1与workSheet2的keyColumn2关联,在workSheet2中找到srcColumn列,写入workSheet1的destColumn,startRow1是workSheet1起始行,startRow2是workSheet2起始行
Sub otherSheetSerch(workSheet1 As Worksheet, workSheet2 As Worksheet, startRow1 As Long, startRow2 As Long, keyColumn1 As Long, keyColumn2 As Long, destColumn As Long, srcColumn As Long)
'总行数,总列数
Dim row_num As Long
Dim rng As Range
Set rng = workSheet1.UsedRange
row_num = rng.Rows.Count
'总行数,总列数
Dim s_row_num As Long
Dim s_rng As Range
Set s_rng = workSheet2.UsedRange
s_row_num = s_rng.Rows.Count
'第X行
Dim r As Long
Dim s_r As Long
Dim tablename As String
Dim s_tablename As String
Dim keyValue1 As String, keyValue2 As String, fiel
vba实现不同表间关联查找
于 2022-05-11 09:15:53 首次发布
![](https://img-home.csdnimg.cn/images/20240711042549.png)