我必须使用VBS查找单元格的值,并以相同的方式获取行号。我已经尝试使用VBA随附的解决方案,但是它们对我没有用。
谢谢。
答案 0 :(得分:0)
卡洛斯,对负面消息表示遗憾。他不会让我脱掉它。我是这里的新手,我不确定这是怎么回事。 我向您发送了代码:
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