Quick VB function question

jferri

Board Regular
Joined
Jun 24, 2003
Messages
58
Quick Question.

In the below function, if "symbol" is the name of various worksheets in my workbook, why is the following function not working?

Thanks!


Public Function theValue(symbol As Variant)

theValue = Sheets(symbol).Cells(1, 5).Value

End Function
 

Excel Facts

What is the fastest way to copy a formula?
If A2:A50000 contain data. Enter a formula in B2. Select B2. Double-click the Fill Handle and Excel will shoot the formula down to B50000.
Try specifying symbol as a string rather than a variant - otherwise if the sheet name is a numerical value (like say '10') the function will actually look for the sheet in the activeworkbook with an index value of 10 rather than a name of '10'.

Richard
 
Upvote 0
It works for me. In what way doesn't it work for you?
 
Upvote 0
cool. it looks like i was being sloppy, and impatient. just needed to wait a bit longer.

thanks for the reply.
 
Upvote 0

Forum statistics

Threads
1,215,059
Messages
6,122,918
Members
449,093
Latest member
dbomb1414

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