A simple macro question

C

CWatters

I know how to open a box so that the user can enter data. eg N1 =
InputBox("Please enter a number")

...but is there a way to do this using a local variable rather than a cell?

For example how would I define "My_number" so that this works...

My_number = InputBox("Please enter a number")

...where My_umber is used in equations elsewhere in the spreadsheet?

Thanks
 
B

Bernie Deitrick

CW,

You can do it with a named range:

Range("My_number").Value = Application.InputBox("Please enter a number")

You would need to create the named range prior to doing this.

Then your users could use

=My_Number

and get that number.

Did any user ever tell you that they hate underscores? They really
interrupt the flow of typing.... just my extra 2 cents worth.

HTH,
Bernie
MS Excel MVP
 
C

CWatters

Bernie Deitrick said:
CW,

You can do it with a named range:

Range("My_number").Value = Application.InputBox("Please enter a number")

Thanks for that I'll giv it a go.

Colin
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top