VB Gets value in Excel

  • Thread starter Thread starter freddyboy2
  • Start date Start date
F

freddyboy2

Guest
Imports Excel = Microsoft.Office.Interop.Excel


Public Class textboxresult

Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
Dim xlApp As Excel.Application
Dim xlWorkBook As Excel.Workbook
Dim xlWorkSheet As Excel.Worksheet


xlApp = New Excel.Application
xlWorkBook = xlApp.Workbooks.Open("D:\Users\PC\Desktop\test.xlsx")
xlWorkSheet = xlWorkBook.Worksheets("sheet1")

Dim Selectedfile As String
Selectedfile = TreeView1.SelectedNode.Text
Select Case Selectedfile

Case Is = "Fred"
TextBox1.Text = xlWorkSheet.Cells(2, 2).value

Case Is = "ted"
TextBox1.Text = xlWorkSheet.Cells(3, 2).value

Case Is = "luc"
TextBox1.Text = xlWorkSheet.Cells(4, 2).value

End Select




So here it goes, I have a treeview and when I choose a name, it returns a specific cell value.

All names are found in an Excel sheet (sheet1) 1st column.

I would to be able to go to the matching string, select that row and move to other column in that same row

in order to get a cell value.

Continue reading...
 
Back
Top