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

How can you automate Excel?
Press Alt+F11 from Windows Excel to open the Visual Basic for Applications (VBA) editor.
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,223,893
Messages
6,175,240
Members
452,621
Latest member
Laura_PinksBTHFT

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