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:

Some videos you may like

Excel Facts

Does the VLOOKUP table have to be sorted?
No! when you are using an exact match, the VLOOKUP table can be in any order. Best-selling items at the top is actually the best.

Joe4

MrExcel MVP, Junior Admin
Joined
Aug 1, 2002
Messages
55,916
Office Version
  1. 365
Platform
  1. Windows
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
 

farmock2

New Member
Joined
Oct 29, 2014
Messages
23
Thanks so much. It has been a while since using macros and forgot that. Your quick response is genuinely appreciated
 

Joe4

MrExcel MVP, Junior Admin
Joined
Aug 1, 2002
Messages
55,916
Office Version
  1. 365
Platform
  1. Windows
You are welcome.
 

Watch MrExcel Video

Forum statistics

Threads
1,122,491
Messages
5,596,462
Members
414,069
Latest member
StudExcel

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
Top