Variable does not accept value

farmock2

New Member
Joined
Oct 29, 2014
Messages
23
I have installed Excel 2016 on a new computer and when I run the following macro, the variable symBol does not
accept the value GDX. It just shows "" as the value. The macro works fine on another computer running Excel 2013.

[TABLE="width: 401"]
<tbody>[TR]
[TD]Sub RunBTSlong()
Dim symBol As String[/TD]
[/TR]
[TR]
[TD]symBol = GDX[/TD]
[/TR]
[TR]
[TD][/TD]
[/TR]
[TR]
[TD]Workbooks.Open Filename:= _[/TD]
[/TR]
[TR]
[TD] "http://www.marketwatch.com/investing/fund/" & symBol
End Sub[/TD]
[/TR]
</tbody>[/TABLE]

Can anybody help? Is there a setting that needs to be changed? Thanks in advance. Frank
 
Last edited:

Excel Facts

Workdays for a market open Mon, Wed, Friday?
Yes! Use "0101011" for the weekend argument in NETWORKDAYS.INTL or WORKDAY.INTL. The 7 digits start on Monday. 1 means it is a weekend.
If you want the literal string GDX, you need to enclose it in quotes, i.e.
Code:
symBol = "GDX"
Otherwise, it is looking for a variable named GDX, which is not set, so has no value, so is equal to "".

If you put "Option Explicit" at the top of your code, it will catch errors like this.
See: http://www.excel-easy.com/vba/examples/option-explicit.html
 
Upvote 0
Thanks so much. It has been a while since using macros and forgot that. Your quick response is genuinely appreciated
 
Upvote 0

Forum statistics

Threads
1,224,819
Messages
6,181,153
Members
453,021
Latest member
Justyna P

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