如何用VB在一个EXCEL文件中搜索给定值,并返回其行和列的值?

来源:百度知道 编辑:UC知道 时间:2024/06/24 08:32:38

Dim xlApp As Excel.Application
Set xlApp = New Excel.Application
Set xlApp = CreateObject("Excel.Application")
strDestination = App.Path & "\temp.xls"
Set xlbook = xlApp.Workbooks.Open(strDestination)
Set xlsheet = xlbook.Worksheets(1)
for x=1 to 65535
for y=1 to 255
if xlsheet.cells(x,y)="定值" then
msgbox x
msgbox y
xlbook.Close
xlApp.Quit '退出EXCEL
exit sub
end if
next y
next x