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

Which came first: VisiCalc or Lotus 1-2-3?
Dan Bricklin and Bob Frankston debuted VisiCalc in 1979 as a Visible Calculator. Lotus 1-2-3 debuted in the early 1980's, from Mitch Kapor.
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,214,649
Messages
6,120,728
Members
448,987
Latest member
marion_davis

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