Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

VBScript reading out Excel CSV file

VBScript reading out Excel CSV file

VBScript reading out Excel CSV file

My script reads out 3 lines (introw 1, 2 and 3). But it only shows the intRow line 2, how can I make the inputbox look for the line in Excel and show it in the message box? Help would be appreciated!

' Read an Excel Spreadsheet

' User enters value
sInp=Inputbox("Enter Identity text")
If sInp = "" Then WScript.Quit
On Error Resume Next
Const ForAppending = 8
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objExcel = CreateObject("Excel.Application")
Set objWorkbook = objExcel.Workbooks.Open_(sFNInput)
Do Until objExcel.Cells(intRow,1).Value = ""
sID=objExcel.Cells(intRow, 1).Value
sType=objExcel.Cells(intRow, 2).Value
sColor=objExcel.Cells(intRow, 3).Value

Introw = 2

' If user entered value matches (row 2 matches value before comma in row 1)
sResult = InStr(1,sID,sInp,1)
If sResult <> 0 Then

'return row 3

' entered value goes in Field 1 of my application

' return value goes in Field2 of my application
Field2= sResult
end if

intRow = Introw + 1
msgbox "productRange: " & sID & " type: " & sType & " colorcode: " & sColor

RE: VBScript reading out Excel CSV file

You never initialize your Introw variable to 1 before the loop.

And without regard to the fact that you increment Introw by 1, you assign Introw to 2 inside your loop???


glassesJust traded in my OLD subtlety...
for a NUance!tongue

"The most incomprehensible thing about the universe is that it is comprehensible" A. Einstein

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close