Contact US

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-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!

*Eng-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

Using VB forms to populate and reference excel cells

Using VB forms to populate and reference excel cells

Using VB forms to populate and reference excel cells


I know that this may seem like a really stupid question but how do you get a value from a combo box which is on a VB form to go into the excel file that the form is associated to.

For example, a value is selected from a combo box on the VB form.  I now want that value to appear in an excel sheet such that i can use it to run calculations etc.

Further to that, how do you then use a text box to look at a field in an excel table and display the value from the excel sheet?

Any help would be greatly appreciated.


David Hair

RE: Using VB forms to populate and reference excel cells

Something like

1) Open the Excel spreadsheet
Set DataFileObj = GetObject("C:\DataFile.xls")

2) Put a value into cell A1
DataFileObj.Worksheets(1).Range("A1").Value = CellValue

2) Get a value from cell A1
CellValue = DataFileObj.Worksheets(1).Range("A1").Value

Did that help?

RE: Using VB forms to populate and reference excel cells


Set the ControlSource property to the linked cell address, e.g. "Sheet1!A1"
If you want a list of items from the spreadsheet to display in the ComboBox, set the RowSource property to the range address, e.g. "Sheet1!B1:B20"
Note that you can do this by VB code or by typing the appropriate references in the properties window (press F4) in the VB editor, when you have the userform displayed and the textbox/combobox selected.


Please see FAQ731-376 for tips on how to make the best use of Eng-Tips.

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 Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

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

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


Close Box

Join Eng-Tips® Today!

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

Here's Why Members Love Eng-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close