Can't assign value to variable

farmock2

New Member
Joined
Oct 29, 2014
Messages
23
In the following macro a value shows in cell A61 when theworkbook opens and remains until
line “Cells(D + 1,"A").Value = intPrice” is executed. It then disappears so no value isassigned to intPrice. Can anybody help with this problem? Thanks in advance forany assistance.
Sub Macro3()
Dim symBol As String
Dim intPrice As String
Dim pRice As Single
Dim D As Integer
Dim T As Integer
symBol = "GDX"
Workbooks.OpenFilename:= _ "https://www.google.com/search?newwindow=1&source=hp&ei=o6yaWqXSOITW5gK4prmIBA&q="& symBol &"&oq=gdx&gs_l=psy-ab.3..35i39k1j0i131i67k1j0i67k1l2j0i20i263k1j0j0i67k1j0l3.1975.2841.0.4149.4.3.0.0.0.0.80.233.3.3.0..2..0...1.1.64.psy-ab..1.3.232.0..0i131k1.0.I8JFR7A7pqU"
D = 1
Do
IfLeft(Cells(D, "A").Value, 8) = "NYSEARCA" Then
Cells(D + 1, "A").Value = intPrice
ExitDo
End If
D = D + 1
Loop Until D =1000
End Sub
 

Excel Facts

Will the fill handle fill 1, 2, 3?
Yes! Type 1 in a cell. Hold down Ctrl while you drag the fill handle.
You have defined intPrice, but you have loaded anything into it, so it is a blank string, so when D gets to 60 A61 gets a blank string written into it.
put this line after the Dim intprice:

Code:
Intprice="Test String"
 
Upvote 0
You're never saying what intPrice is equal to. The value in Cells(D + 1, "A") is disappearing because intPrice is null. You need something like this...

Code:
intPrice = 5
Cells(D + 1, "A").value = intPrice
 
Upvote 0

Forum statistics

Threads
1,223,230
Messages
6,170,883
Members
452,364
Latest member
springate

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