Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations John Tel on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Filling Text Boxes With Excel Data

Status
Not open for further replies.

Shfog

Programmer
Aug 24, 2001
20
US
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 <> &quot;&quot; Then conExcel.Close
conExcel.Open &quot;DRIVER=Microsoft Excel Driver (*.xls); DBQ=&quot; + cmnDlgs.FileName
'
If rstExcel.State Then rstExcel.Close
rstExcel.Open &quot;SELECT * FROM [&quot; + txtWorkSheetName.Text + &quot;$]&quot;, 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
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top