PDA

View Full Version : Multiply VBA InputBox value by cell value derived from json API URL Web Query



cypher
11-19-2018, 08:23 PM
I'm new to VBA and have been trying various things for hours but I can't seem to figure out how to simply multiply a decimal user input of 1.1 by the cell value of C1 or C3 (71388.92). Here is what I've tried last:


Private Sub CommandButton1_Click()
Dim myValue As Variant

myValue = InputBox("Prompt", "Title")
Range("C5").Value = myValue * Range("C1")

End Sub

I get a runtime error '13'- Type mismatch because cell C1's value is derived from from json web query. I've tried Variant, Double, Single, Long and Data Types: Decimal, Number and Currency.

Kenneth Hobs
11-20-2018, 08:27 PM
Welcome to the forum!

That sort of inputbox returns a string. Use Val() to convert the number string to a number.

myValue = Val(InputBox("Prompt", "Title"))

cypher
11-20-2018, 09:02 PM
Thank you so much!