VBA代码转换成VB代码的问题。
Subtest()DimrngAsRangeForEachrngInRange("A1:G20")Ifrng="合计"Thenrng.SelectNextEndSub请问...
Sub test()
Dim rng As Range
For Each rng In Range("A1:G20")
If rng = "合计" Then rng.Select
Next
End Sub
请问这段代码如何转换成VB代码?十分感谢! 展开
Dim rng As Range
For Each rng In Range("A1:G20")
If rng = "合计" Then rng.Select
Next
End Sub
请问这段代码如何转换成VB代码?十分感谢! 展开
2个回答
展开全部
Dim oExcel
Dim oBook
Dim osheet
Set oExcel = CreateObject("Excel.Application")
Set oBook = oExcel.Workbooks.Open(App.Path & "\Excel.xls")
Set osheet = oBook.Worksheets(1)
For icol = 1 To 7
For irow = 1 To 20
If osheet.cells(irow, icol) = "合计" Then
MsgBox "OK"
End If
Next irow
Next icol
Dim oBook
Dim osheet
Set oExcel = CreateObject("Excel.Application")
Set oBook = oExcel.Workbooks.Open(App.Path & "\Excel.xls")
Set osheet = oBook.Worksheets(1)
For icol = 1 To 7
For irow = 1 To 20
If osheet.cells(irow, icol) = "合计" Then
MsgBox "OK"
End If
Next irow
Next icol
追问
如果查到这个数据,怎么删除?你给的数据能查到,但是没有选定,所以不知道该怎么删除,十分感谢。
追答
osheet.cells(irow, icol) =""
本回答被提问者和网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询