如何用VB在一个EXCEL文件中搜索给定值,并返回其行和列的值?
展开全部
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
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
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询