请问这个VBA程序怎么更改?
Subcheck()DimiAsIntegerDimsAsIntegers=InputBox("请输入查找内容")Fori=1To1000IfCells(1,i)=sTh...
Sub check()
Dim i As Integer
Dim s As Integer
s = InputBox("请输入查找内容")
For i = 1 To 1000
If Cells(1, i) = s Then
Exit For
End If
Next
's = Worksheets("sheet2").Row(i)
If (i > 1000) Then
MsgBox "not find"
Else
MsgBox i
End If
End Sub 展开
Dim i As Integer
Dim s As Integer
s = InputBox("请输入查找内容")
For i = 1 To 1000
If Cells(1, i) = s Then
Exit For
End If
Next
's = Worksheets("sheet2").Row(i)
If (i > 1000) Then
MsgBox "not find"
Else
MsgBox i
End If
End Sub 展开
3个回答
2011-04-03
展开全部
Sub check()
Dim i As Integer
Dim s As Integer
s = InputBox("请输入查找内容")
For i = 1 To 1000
If Cells(1, i) = s Then
MsgBox "找到" & i & "列 " & Cells(1, i)
Exit Sub
End If
Next
MsgBox "not find"
End Sub
Dim i As Integer
Dim s As Integer
s = InputBox("请输入查找内容")
For i = 1 To 1000
If Cells(1, i) = s Then
MsgBox "找到" & i & "列 " & Cells(1, i)
Exit Sub
End If
Next
MsgBox "not find"
End Sub
展开全部
2003的Excel表总共才256列(2007好象多点),所以For i = 1 To 1000,从列中查数据,查不到就会出错的。是否If Cells(1, i) = s Then这句搞错了,应该为If Cells(i,1) = s Then
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
Sub check()
Dim i As Integer
Dim s As String
s = InputBox("请输入查找内容")
For i = 1 To 1000
If Cells(1, i) = s Then
Exit For
End If
Next
's = Worksheets("sheet2").Row(i)
If (i > 1000) Then
MsgBox "not find"
Else
MsgBox i
End If
End Sub
Dim i As Integer
Dim s As String
s = InputBox("请输入查找内容")
For i = 1 To 1000
If Cells(1, i) = s Then
Exit For
End If
Next
's = Worksheets("sheet2").Row(i)
If (i > 1000) Then
MsgBox "not find"
Else
MsgBox i
End If
End Sub
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询