Vbscript 如何使用vbs在单元格中查找值
我必须找到一个单元格的值,并以同样的方式得到行数,使用VBS。我尝试过VBA附带的解决方案,但它们对我不起作用Vbscript 如何使用vbs在单元格中查找值,vbscript,Vbscript,我必须找到一个单元格的值,并以同样的方式得到行数,使用VBS。我尝试过VBA附带的解决方案,但它们对我不起作用 谢谢。卡洛斯,很抱歉负面消息。他不让我脱下来。我是新来的,我不知道这是怎么回事。 我向您发送代码: Set WshShell = WScript.CreateObject("WScript.Shell") Set fso = CreateObject("Scripting.FileSystemObject") Route=(fso.GetParentFolderName(WScri
谢谢。卡洛斯,很抱歉负面消息。他不让我脱下来。我是新来的,我不知道这是怎么回事。 我向您发送代码:
Set WshShell = WScript.CreateObject("WScript.Shell")
Set fso = CreateObject("Scripting.FileSystemObject")
Route=(fso.GetParentFolderName(WScript.ScriptFullName))&"\" ' Route = folder
Set objExcel1 = createobject("Excel.application") 'we create Excel object
objExcel1.Visible = True 'we make it visible
Set objWorkbook = objExcel1.Workbooks.open (Route&"Book.xlsx") 'we open it
Set objSheet = objExcel1.ActiveWorkbook.Worksheets(1) 'we select the sheet num 1
value="Hello" ' Hello is an example, is the value that we are going to look for
yy=30 'We assume we have a sheet of 30 rows
xx=40 'and 40 columns
For y1=1 to yy
cc=0 'control variable
For x1=1 to xx
if objExcel1.Cells(y1, x1).Value=value then cc=1 :exit for '
next
if cc=1 then exit for 'cc=1 we leave the second loop
next
If cc=1 then Msgbox " Found value in Column="&x1 &" Row="&y1
if cc=0 then Msgbox "Value not found"
msgbox "End",4096