Link to home
Start Free TrialLog in
Avatar of mnoisette
mnoisetteFlag for United States of America

asked on

VBA Prompt to enter the same data in multiple cells on multiple worksheets.

I have an Excel 2007 Workbook with mutiple worksheets. On Sheets 2, 3, 4, 5, and 6 the data is in the same location. I would like a macro that will put the same data in the same cell on each on of those sheets... e.g. (Sheet1:Sheet6!B4).
When the macro runs, I would like a prompt that will ask the user what the input will be...
Avatar of jan24
jan24
Flag of United Kingdom of Great Britain and Northern Ireland image

Hi mnoisette.
I know you asked for a macro, but before we go down that route let me just check in case the following delivers the functionality you need.
If you select all those sheets (i.e. select multiple sheets at once by CTRL-click or SHIFT-click on the tabs) then, when you enter data, it will enter it on all the sheets at once.  For example if you entered "hello" in cell A1, then "hello" would appear in cell A1 on all of the selected sheets.
It works with entering formulae too.
Avatar of Rob Henson
If there is data copied between sheets, why not have one input sheet and have the other sheets linked to that input sheet.

Using Jan24's example

Sheet1!A1 > Hello   (manual entry)
Sheet2!A1 > =Sheet1!A1  (formula entry, copying sheet 1 entry).
Sheet3!A1 > =Sheet1!A1  (formula entry, copying sheet 1 entry).

If this is the way to go, as mentioned by jan24, doing the multiple sheet select when entering the formula on the linked sheets will enter the same formula in the same cell on all selected sheets.

Apologies if making it sound too simplistic.

Thanks
Rob H
Avatar of mnoisette

ASKER

That is correct. I do know that method for three demesional data, but there are many sheets and many cells that need the info. If the macro is set up ocnce, it would prevent the user from leaving out a cell when selecting the cells for the data. It may need to be something like (Sheet1:Sheet10!A1,D1, F1, H1) just as an example.
The reference cell may be an option, but for some reason, these people are bent on doing a macro.
Can we guarantee that the sheetnames will always be Sheet1, Sheet2, Sheet3, etc etc
If so then your suggested format Sheet1:Sheet10 should work.
If not, it may be best if the macro gives a dialog box where the user can select the desired sheets.
Which of those approaches works best for you?
Jan24:
The sheet names are a constant as well as the cells....
Here's an attempt using the first of the two approaches.   Instructions:
1) Click the button "Enter data on multiple sheets"
2) Fill in the sheets you want to process, e.g. Sheet1:Sheet10
3) Fill in the range you want to affect, e.g. A1,D1, F1, H1
4) Fill in the value you want to enter
5) Click OK

It assumes that your sheets are all named Sheet1, Sheet2, etc.  If you enter Sheet1:Sheet10 and Sheet7 was missing then it will throw an error and do nothing.  I thought this was the safest behaviour.  If you would instead like it to skip Sheet7 and carry on then let me know.
Book11.xlsm
Is there a way to enter the sheet names if they are non-adjacent? And, the sheet names are constant, but they are not named "Sheet". The cell and and the text part work perfectly!
Sure.  I can see two ways of doing it:
1) Have a multiselect in the dialog box, so you can select whichever sheets you want (and shift-click) to select a range.  This would allow it to cope with any sheet names.
2) Use a format like 'Sheet1:Sheet5,Sheet7,Sheet9:Sheet10' as for the cell references.

(1) is probably easier if it's all the same with you, but let me know which you prefer.
Also, if you want to go with (2) then I'll need you to tell me what they are all called if it isn't 'Sheet'.
Going with number 1 would be the better one....
Thanks!
ASKER CERTIFIED SOLUTION
Avatar of jan24
jan24
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Beautiful! That's what I needed....
Awesome!!!
You're welcome!