Input Box

h0l1yw0od

New Member
Joined
Oct 6, 2005
Messages
21
Hi everyone,

Could someone help me with the code for an input box please.

I've got it to display the box but i need to put in the code that will send the input data to a cell on another page and add it to the figure already there.

The code i have so far is:

---
Dim NumberOfItems As String
NumberOfItems = InputBox("How many items were in the batch?", "Enter Amount.")
---

The sheet the figure needs to go to is Staff, cell A57.

Thanks,
 

Excel Facts

How to total the visible cells?
From the first blank cell below a filtered data set, press Alt+=. Instead of SUM, you will get SUBTOTAL(9,)
Try this:
Code:
    Dim NumberOfItems As Double
    NumberOfItems = InputBox("How many items were in the batch?", "Enter Amount.")
    Sheets("Staff").Range("A57") = Sheets("Staff").Range("A57") + NumberOfItems
Note: I changed your field to a numeric entry.
 
Upvote 0
Sub getData()
'Sheet module code, like: Sheet1
Dim NumOfItems&

NumOfItems = InputBox("How many items were in the batch?", "Enter Amount.")
Sheets("Staff").Range("A57").Value = Sheets("Staff").Range("A57").Value + NumOfItems

End Sub
 
Upvote 0
Great, stuff.

Thanks guys.

Edit:

Ah, hang on a mo. I forgot that there are a range of sheets to choose from.

Basically when the macro is run it has to look at cell C4 to see what name is in the box and then apply the amount from the input box to the appropriate sheet.

Sorry. :rolleyes:
 
Upvote 0
Try making the change, post your code if you get stuck.

To help: Record a macro for the basic steps and then modify the recorded code to work with general selections rather than the recorded specific selections.
 
Upvote 0
I've got the code i was after as far as moving the data from one sheet to another based on using the employee name in C4 and sending the info from the input box to the appropriate worksheet. The code being:

Worksheets(Range("C4").Value).Range("A57").Value = NumberOfItems

The one thing I'm now having trouble figuring out is how to make the number from the input box add itself to the contents of A57 as opposed to overwriting whats already there.

I know this sounds daft but i've tried several combinations but just cannot find the correct phrase to use or the place where to put it. I assume it should be something like:

Worksheets(Range("C4").Value).Range("A57").Value = Range("A57") + NumberOfItems

If someone can help with how to make that work then that would be great.

Thanks again.
 
Upvote 0
Did you try:

Worksheets(Range("C4").Value).Range("A57").Value = Worksheets(Range("C4").Value).Range("A57").Value + NumberOfItems
 
Upvote 0

Forum statistics

Threads
1,212,094
Messages
6,105,929
Members
447,984
Latest member
imrics

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