excel - Storing user inputs for retrieving later -
i have spreadsheet user inputs various details on inputs page , presses calculate button want. inputs strings, numbers , dates.
i want save inputs each calculation user @ later date enter calc id , not have renter inputs.
one simple way thought of doing copy inputs when calculation run sheet inputs in column calc id. save future inputs in separate column , lookup correct column retrieve inputs @ later date.
i read question - what benefits of using classes in vba? , thought make class called calculationinputs had details stored in 1 object. may overkill need wanted ask how other people solve simple task.
you can use names define variables within scope of workbook or worksheet. typically these used define ranges, , more dynamic ranges, can used store static/constant values.
to create name manually, formula ribbon, names manager:

click on "new" button, , give meaningful name:

make sure put ="" in "refers to" field, if leave blank, name not created.
then when press ok, or time go names manager, see list of available names in workbook.

you can edit these through names manager, tedious, or can use vba , inputs control them, example:
sub test() activeworkbook.names("myaddress").refersto = "734 evergreen terrace" end sub you capture value, our use other macros or user firm code assign value name.
activeworkbook.names("myaddress").refersto = _ application.inputbox("please enter address") etc.
if run this, , review names manager, you'll see value has been updated:

in vbe, can refer name like:
debug.print activeworkbook.names("myaddress").value '# prints in immediate pane range("a1") = activeworkbook.names("myaddress").value these can accessed (read) worksheet, like:

Comments
Post a Comment