I have some code that will allow me to pull data from a normal Excel sheet into a list view in VB.
Can this code be modified to allow me to select only certain cells (same ones each time) and put them into text boxes so that they can be modified or edited?
If conExcel.ConnectionString <> "" Then conExcel.Close
conExcel.Open "DRIVER=Microsoft Excel Driver (*.xls); DBQ=" + cmnDlgs.FileName
'
If rstExcel.State Then rstExcel.Close
rstExcel.Open "SELECT * FROM [" + txtWorkSheetName.Text + "$]", conExcel, adOpenDynamic, adLockOptimistic
'
For intCtr = 0 To rstExcel.Fields.Count - 1 Step 1
Set clmHead = lvwXL.ColumnHeaders.Add(, , rstExcel.Fields(intCtr).Name)
Next intCtr
'
Do Until rstExcel.EOF
Set lstItem = lvwXL.ListItems.Add(, , rstExcel.Fields(0))
For intCtr = 1 To rstExcel.Fields.Count - 1 Step 1
lstItem.SubItems(intCtr) = rstExcel.Fields(intCtr)
Next intCtr
rstExcel.MoveNext
Loop
Can this code be modified to allow me to select only certain cells (same ones each time) and put them into text boxes so that they can be modified or edited?
If conExcel.ConnectionString <> "" Then conExcel.Close
conExcel.Open "DRIVER=Microsoft Excel Driver (*.xls); DBQ=" + cmnDlgs.FileName
'
If rstExcel.State Then rstExcel.Close
rstExcel.Open "SELECT * FROM [" + txtWorkSheetName.Text + "$]", conExcel, adOpenDynamic, adLockOptimistic
'
For intCtr = 0 To rstExcel.Fields.Count - 1 Step 1
Set clmHead = lvwXL.ColumnHeaders.Add(, , rstExcel.Fields(intCtr).Name)
Next intCtr
'
Do Until rstExcel.EOF
Set lstItem = lvwXL.ListItems.Add(, , rstExcel.Fields(0))
For intCtr = 1 To rstExcel.Fields.Count - 1 Step 1
lstItem.SubItems(intCtr) = rstExcel.Fields(intCtr)
Next intCtr
rstExcel.MoveNext
Loop