Results 1 to 4 of 4

Thread: Reading excel file (row,column) and display results

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Jan 2007
    Location
    Richmond, VA
    Posts
    17

    Reading excel file (row,column) and display results

    Good morning,

    I am working on a calculation process that has various text boxes and combo boxes, and also creates an Excel session and opens the needed Excel file. So far, so good....

    What I need to do is compare one of the text box values to a certain row/column on the spreadsheet.

    Let's say, text1.Text = "200"

    So, now while the Excel worksheet is open and running, it needs to locate where "200" is, by matching text1.Text to a certain row/column variable.

    Example:
    .....A..........B.........C..........D..........E
    1...50........175......100.......75........125
    2...60........120.......80........140......110
    3...90........200......150.......70........115

    Is this very difficult to do? I can get it to open up and display the Excel worksheet, but I don't understand how to compare a value from a text box to a certain row/column of a spreadsheet.

    Thank you!

    Butch A.

  2. #2
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,974

    Re: Reading excel file (row,column) and display results

    It seems that this may not be the right forum for your question, but I can move it later if needed.

    How are you actually working with Excel at the moment?

    If you are using automation as shown in my tutorial (which I think you might be, based on your "Just signed up" thread!) then you could use something like this:
    VB Code:
    1. If Text1.Text = oXLSheet.Range("B3").Text Then  'or:   If Text1.Text = oXLSheet.Cells(3,2).Text Then
    2.   Msgbox "Same"
    3. Else
    4.   Msgbox "Different"
    5. End if
    ..I may have mis-interpeted what you meant tho, so tell me if I have!

  3. #3

    Thread Starter
    Junior Member
    Join Date
    Jan 2007
    Location
    Richmond, VA
    Posts
    17

    Re: Reading excel file (row,column) and display results

    Thanks, Si...

    Yes, I am using your examples and didn't know exactly which would be the best way to achieve the results.

    I didn't know if my VB6 and Excel spreadsheet program should be posted here, but I figured I'd try it here. You can move it back to the Classic VB threads if needed.

    Thank you!

    Butch A.

  4. #4
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,974

    Re: Reading excel file (row,column) and display results

    I think the "Office Development" forum is probably best, so I have moved it there.

    If you have more questions about using Excel from VB, this is the forum that is likely to get the best results (just make sure you specify that you are automating Excel from VB, so that people dont get confused!).

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width