You are here:

Visual Basic/Visual Basic program

Advertisement


Question
Excel Sheet Image
Excel Sheet Image  
User Form Design
User Form Design  
QUESTION: Hi,

I am working on MS Excel. I have created a VB form which i attached a image copy in which you will find a combo box drop down list which contain name of services. I have a master excel sheet named "Accounting code" which contain Name of Service with its respective codes.
My problem is i do not know much about VB, hence i want a program that auto fill up the other combo box in form (which are on left side in the Middle of Image) with corresponding data form the excel sheet which i mentioned above based on the name of the service i select from the drop down list from combo box. Is it possible in a same way like vlookup in excel? I am also attaching a excel sheet image copy. Hope i am clear.

ANSWER: What version of Visual Basic are you using?  Visual Basic 6 or Visual Basic .NET?

Kevin

---------- FOLLOW-UP ----------

QUESTION: Hi, Kevin,

Thank you for your response.
I am using VB 6.5 version

Answer
Hi Ramachandra
Take a look at the link below.  It should at least get you started.  If you have any questions please do not hesitate to ask a followup question.
http://www.developerfusion.com/code/5322/working-with-excel-files-using-vb6/

Just some thoughts on the code:
you need to add a reference 'to the Microsoft excel 'xx' object library. Where XX refers to the version of Excel you are using.  You most likely one have one version istalled.  I am not sure but I believe each computer has to have the same version of Excel

You must have these three lines
Dim xl As New Excel.Application  
Dim xlwbook As Excel.Workbook
Dim xlsheet As Excel.Worksheet

XL is used to refer to an instance of Excel
XLwbook is used to refer to a workbook
XLsheet refers to a worksheet  You can refer to multiple sheets if you want

Kevin

Visual Basic

All Answers


Answers by Expert:


Ask Experts

Volunteer


Kevin Watkins

Expertise

I have written several programs integrating with MS Office including Access, Excel, and Word. I have used control arrays as well as data arrays, text files. I have an associates degree in programming. Please do not ask questions about VBA or dot net. I can only answer questions about Visual Basic 6.

Experience

I have written several programs integrating with MS Office including Access, Excel, and Word. I have used control arrays as well as data arrays, text files. I have an associates degree in programming.

Education/Credentials
I have an associates degree in computer programming.

©2016 About.com. All rights reserved.