Basic Visual Basic Form

harrigme

New Member
Joined
Mar 8, 2011
Messages
2
This may be an easy question for many of you.

I want to create a Form in VB that I can use to reference an excel spreadsheet in Excel. For example, I would like to have several text boxes and in one text box I enter a stock symbol and then in the other boxes, the information from the spreadsheet is populated, such as market cap, volume, industry, etc...

Any help would be appreciated.

Thanks!
 

Excel Facts

Can a formula spear through sheets?
Use =SUM(January:December!E7) to sum E7 on all of the sheets from January through December
Hi there,

You could maybe do it like this:

Create your form, add your textboxes and a command button.

In the command button code (double click on it) enter:

Code:
Private Sub CommandButton1_Click()
    sSymbol = TextBox1.Value
    
    TextBox2.Value = WorksheetFunction.VLookup(sSymbol, Range("A1:E100"), 2, False)
    TextBox3.Value = WorksheetFunction.VLookup(sSymbol, Range("A1:E100"), 3, False)
...
End Sub

This is assuming your data is in the Range A1:E100 and the Stock Symbol is in column A. Change as required.
 
Upvote 0
Thanks! That helps a lot.

Another question. It gives me an error when a field is blank. Anyway to correct that?
 
Upvote 0

Forum statistics

Threads
1,224,557
Messages
6,179,508
Members
452,918
Latest member
Davion615

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top