adds a number input into an input box to the value in cell D4. The result should be output in cell G12.

Katerina 6 Reputation points
2021-05-09T14:39:33.717+00:00

Hi all , I ´m studding at one course of vba programming and cannot resolve this:
Create a subroutine that adds a number input into an input box to the value in cell D4. The result should be output in cell G12.
I think that i´m doing everything weill, but it does not work:
Sub AddNumbersA()
Dim x As Double, y As Double
On Error GoTo Here
x = InputBox("Enter a number:")
y = Range("D4")

Range("G12") = x + y
Exit Sub
Here:
MsgBox ("There was an error")
End Sub

I added error(goto) , added .value to range, but nothing. And by the way F8 is working properly and the code as well, but when I submit it I ´ve the reply that it is incorrect.
Can anyone help me please?
Thank you

{count} vote