Capturing Value from InputBox

sahaider

New Member
Joined
May 30, 2014
Messages
35
Hello All,

I have two sub procedures. In sub procedure1 i call sub procedure 2 . In sub procedure 2 I have an inputbox that asks users to enter a city name and stores that as a variable and then some other operations are performed. when I return to sub procedure 1 I would like to insert the stored variable name i.e city name that was captured in sub procedure 1 in a worksheet cell D2.
but its not working as expected, any help is apprecaited.

Here is the code:

VBA Code:
Public Sub sub1()
enter_city

Worksheets("Pivot & Reporting").Range("D2").Value = city


End Sub


Sub enter_city()

city = InputBox("Please enter City/town or Area name for which Drive Route has been created", "Drive Route Length Statistics Creation", "Type here")

End Sub
 

Excel Facts

Workdays for a market open Mon, Wed, Friday?
Yes! Use "0101011" for the weekend argument in NETWORKDAYS.INTL or WORKDAY.INTL. The 7 digits start on Monday. 1 means it is a weekend.
One way
VBA Code:
Public Sub sub1()
Dim city As String

enter_city city

Worksheets("Pivot & Reporting").Range("D2").Value = city

End Sub


Sub enter_city(ByRef city As String)

city = InputBox("Please enter City/town or Area name for which Drive Route has been created", "Drive Route Length Statistics Creation", "Type here")

End Su
b
 
Upvote 0

Forum statistics

Threads
1,224,822
Messages
6,181,165
Members
453,021
Latest member
Justyna P

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