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
 
Ok, I understand. The reason it has been marked as wrong is you are not doing this part
adds that number to the value in the active cell
All you are doing is putting the value of x into the active cell & also into the cell 3 rows up & two columns to the right.
 
Upvote 0

Excel Facts

Excel motto
Not everything I do at work revolves around Excel. Only the fun parts.
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
Almost, you need to add x & y when you put it into the cell
 
Upvote 0
hi dear i need your help this question , iam still dont know how to solve it?
b) 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. (Make sure that you select an appropriate active cell prior to running the sub!)

My solution

Sub AddNumbersB()
Dim x As Double, y As Double
x = ActiveCell.Value
y = InputBox("please enter number:")
ActiveCell.Offset(-3, 2).Value = y

End Sub


but i still have a problem that the auto answer told me that my answer is incorrect
 
Upvote 0

Forum statistics

Threads
1,214,911
Messages
6,122,198
Members
449,072
Latest member
DW Draft

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