Monday, October 30, 2017

To check whether the perticular value is present into excel sheet

Function fnIsExistInExcelColumn(inputFilePath,excelSheetName,columnHeader,textValue)

Dim con,rs
Dim varme
Set con=createobject("ADODB.connection")
Set rs=createobject("ADODB.recordset")

con.open "DRIVER={Microsoft Excel Driver (*.xls, *.xlsx, *.xlsm, *.xlsb)};DBQ="&inputFilePath&";Readonly=True"
varme="SELECT count(*) FROM ["&excelSheetName&"$] where "&columnHeader&" = '"&textValue&"' "
rs.open varme,con
fnIsExistInExcelColumn= rs(0)

'Release objects
Set rs= nothing
Set con= nothing

End Function

No comments:

Post a Comment