Help me with VBA codes.

eydani

New Member
Joined
Nov 14, 2014
Messages
16
Hi
where is problem with VBA code?i dont know why i got error and tell it is incorrect
Create a subroutine called AddNumbersB that asks the user for a number, adds that number to the value in the active cell, then places the result in a cell that is 3 rows up and two columns right of the active cell.

Sub AddNumbersB()
Dim x As Double
x = InputBox("input your number:")
ActiveCell.Value = x
ActiveCell.Offset(-3, 2).Value = x
End Sub
 

Excel Facts

Excel motto
Not everything I do at work revolves around Excel. Only the fun parts.
What error did you get & what line is highlighted if you click debug?
Also what was the active cell when you got the error?
 
Upvote 0
What error did you get & what line is highlighted if you click debug?
Also what was the active cell when you got the error?
for places the result in a cell that is 3 rows up and two columns right of the active cell this code is correct?
ActiveCell.Offset(-3, 2).Value = x
 
Upvote 0
Can you please answer my questions.
 
Upvote 0
Can you please answer my questions.
i have online course , it is a question, i run this code without problem in my system,(see image uploaded) , but when i upload my codes , to go next course i got error it is incorrect and i don't know why
 

Attachments

  • excelll.jpg
    excelll.jpg
    149.6 KB · Views: 50
Upvote 0
If you do not answer my questions, it's very difficult to help.
 
Upvote 0
What error did you get & what line is highlighted if you click debug?
Also what was the active cell when you got the error?
you means this "What error did you get & what line is highlighted if you click debug?"
i don't get any error and run VBA without any error
 
Upvote 0
adds that number to the value in the active cell

Reads to me that they want you to add the number entered into the inputbox to a number that already exists in the active cell, and place the result in the offset cell. You are putting the inputbox value into the activecell and the offset cell and not adding anything.
 
Upvote 0
Solution

Forum statistics

Threads
1,215,436
Messages
6,124,869
Members
449,192
Latest member
MoonDancer

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