07-11-2017, 07:41 PM
How to use code of attaching excel sheet so that it can take input from excel of desirable row and column and can also be able to put data to excel during run time .
Right now i am using this code but not able to take input from 2nd,3rd row n so on.....
Public Function GetInputFromExcel(InputFilePath,sheetName,VariableName)
set objExcel = createobject("excel.application")
objExcel.DisplayAlerts=false
set objWB = objExcel.workbooks.open (InputFilePath)
set objsheet = objwb.worksheets(sheetName)
For j = 1 to objsheet.usedrange.columns.count
If Ucase(objsheet.Cells(1,j).value) = Ucase(VariableName) Then
GetInputFromExcel = objsheet.Cells(2,j).value
Exit For
End If
Next
objWb.save
objWB.close
objExcel.Quit
set objExcel=nothing
End Function
Right now i am using this code but not able to take input from 2nd,3rd row n so on.....
Public Function GetInputFromExcel(InputFilePath,sheetName,VariableName)
set objExcel = createobject("excel.application")
objExcel.DisplayAlerts=false
set objWB = objExcel.workbooks.open (InputFilePath)
set objsheet = objwb.worksheets(sheetName)
For j = 1 to objsheet.usedrange.columns.count
If Ucase(objsheet.Cells(1,j).value) = Ucase(VariableName) Then
GetInputFromExcel = objsheet.Cells(2,j).value
Exit For
End If
Next
objWb.save
objWB.close
objExcel.Quit
set objExcel=nothing
End Function