問題描述
使用文本格式的用戶定義輸入從 excel 中檢索數據 (Retrieving data from excel with user defined input that is in text format)
The problem is I am able to extract the data by giving cell reference like:
TextBox1.Text = objWorksheet.Cells(5, 2).value
But I want to select a row as per input given by user and want to extract data from that row.
The input given by user is in text format, in my case name of employee. And I have to extract address of that name.
Please help me, I'mm working on it from last two days but not getting anything...
Code:
Dim objExcel As New Excel.Application ' Represents an instance of Excel
Dim objWorkbook As Excel.Workbook 'Represents a workbook object
Dim objWorksheet As Excel.Worksheet 'Represents a worksheet object
objWorkbook = objExcel.Workbooks.Open("C:\record.xls")
objWorksheet = CType(objWorkbook.Worksheets.Item("CC1"), Excel.Worksheet)
TextBox1.Text = objWorksheet.Cells(5, 2).value
‑‑‑‑‑
參考解法
方法 1:
You have to cycle the column with employee names, and when you find what you're looking for move to the column you're interested in on the same row.
(by gitika gupta、Albireo)