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.

Sub RunBTSlong()
Dim symBol As String
symBol = GDX
Workbooks.Open Filename:= _
"http://www.marketwatch.com/investing/fund/" & symBol
End Sub

<tbody>
</tbody>

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

Excel Facts

Back into an answer in Excel
Use Data, What-If Analysis, Goal Seek to find the correct input cell value to reach a desired result
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,214,521
Messages
6,120,018
Members
448,937
Latest member
BeerMan23

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