Get column values after doing a Find in Excel using VBScript -
i use following code find specific text in whole excel sheet , able specific cell. information, wanted read each of column values active row.
dim objxl const xlwhole = 1 set objxl = createobject("excel.application") objxl.workbooks.open ("c:\config.xls") set objworksheet = objxl.worksheets("sheet1") set objrange = objworksheet.usedrange set objtarget = objrange.find("honda", , , xlwhole) ' searched value on column 3.
i tried using offset method , seems work:
msgbox objtarget.offset(, -2).value
the excel sheet has 7 columns , passing -2 offset method gets me value in first column. how first , last column indexes dynamically row pass them offset method. or better, able column values based on column names.
thanks.
not entirely clear want, first cell in row probably:
cells(objtarget.row, objrange.column)
and last cell
cells(objtarget.row, objrange.columns(objrange.columns.count).column)
a range object representing entire row be:
objrange.rows(objtarget.row)
Comments
Post a Comment