|
发表于 2017-6-22 23:40
来自手机
|
显示全部楼层
本帖最后由 lss001 于 2017-6-29 23:25 编辑
根据下拉列表查询工资如下
Sub chx()
Application.ScreenUpdating = False
Dim c&, d&, j&, k&, r&, s&, m%, n%, y&
Sheets("查询").select
x = Range("c3"): a = Cells(3, 7): b = Cells(3, 9)
If a > b Then Exit Sub
For i = 1 To Worksheets.Count
If a = 201700 + i Then m = i
If b = 201700 + i Then n = i + 2
Next
c = Cells(Rows.Count, 1).End(xlUp).Row + 2
Range("a7:aa" & c) = ""
For Each sht In Worksheets
d = d + 1
If sht.Index > m And sht.Index < n Then
sht.Select
y = Cells(Rows.Count, 1).End(xlUp).Row
If Cells(y, 1) <> "" Then
ReDim cr(1 To y - 5, 1 To 27)
br = Range(Cells(6, 2), Cells(y, 27))
For j = 1 To y - 5
If br(j, 1) = x Then
r = 1:cr(r, 1) = sht.Name
For k = 2 To 27:cr(r, k) = br(j, k - 1):Next
r = r + 1
End If
Next
s = Sheets("查询").Cells(Rows.Count, 1).End(xlUp).Row + 2
Sheets("查询").Cells(s, 1).Resize(y - 5, 27) = cr
End If
End If
Next
Sheets("查询").Select
Range("C3").Select
Application.ScreenUpdating = True
End Sub |
|