Select cell during runtime and continue

james.rees02

New Member
Joined
Mar 26, 2009
Messages
5
Hi - am developing a macro for users to use and need help refining one part of it.
Essentially, the user selects a cell, then clicks a button to run a macro. This is the "From" cell. The macro then needs a "To" cell address to be able to complete. I have got it working using the following code:
Dim RngTo As Range
Set RngTo = Application.InputBox("select cell", Type:=8)

but it opens up an input box with OK/Cancel buttons......where the user selects the cell then clicks OK.

Ideally, what I'd like to see is the macro continuing as soon as the user clicks the cell.....removing the need to click OK....(small step I know but I'm like that :))

What is the code that would enable this. Any help is appreciated.

Thanks.
 

Excel Facts

Using Function Arguments with nested formulas
If writing INDEX in Func. Arguments, type MATCH(. Use the mouse to click inside MATCH in the formula bar. Dialog switches to MATCH.
James,
Not possible with InputBox. (It is logical too. How would InputBox know, when you have finished selecting!)

You can try:
Let user select BOTH "From and "To" cells using Ctrl+Click (need to be on same sheet). Then click the macro button.
In the macro use Selection.Address, Left/Mid to parse the 2 addresses.
Thus:
tmp = Selection.Address
Set rngfrom = Range(Left(tmp, InStr(tmp, ",") - 1))
Set rngTo = Range(Mid(tmp, InStr(tmp, ",") + 1, Len(tmp)))

HTH
 
Last edited:
Upvote 0

Forum statistics

Threads
1,215,029
Messages
6,122,760
Members
449,095
Latest member
m_smith_solihull

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