excel vba 查找行号
发布网友
发布时间:2022-05-03 03:29
我来回答
共1个回答
热心网友
时间:2023-10-08 23:23
Sub lxx()
Dim H As Integer '总行数
H = 1000 '假定总行数为1000,根据需要改
Dim I As Integer '定义行变量
Dim J
For I = 1 To H
If Worksheets("sheet1").Cells(I, 2).Value = "10月份" Then
Worksheets("sheet1").Cells(1, 1).Value = I
Worksheets("sheet1").Cells(2, 1).Value = I
J = I
GoTo Next1:
End If
Next
Next1:
For J = 1 To H
If Worksheets("sheet1").Cells(J, 2).Value = "10月份" Then
Worksheets("sheet1").Cells(2, 1).Value = J
End If
Next
End Sub